Compare commits
33 Commits
shell-tool
...
nbtk-intro
Author | SHA1 | Date | |
---|---|---|---|
4f070317d2 | |||
661100abe8 | |||
3e90b11cfb | |||
4b4a1be420 | |||
1a4861ec4f | |||
2ac82da232 | |||
8f7e6f8117 | |||
d2b98701be | |||
faeda5dc8b | |||
70cb8e180b | |||
2232a92ba8 | |||
4743a8e750 | |||
e1390c7dd5 | |||
49ba54820c | |||
8ffa161a7f | |||
0eca3efcb0 | |||
9c3af62dc4 | |||
db0c2b5959 | |||
98215f497d | |||
9dbafe156e | |||
277dd7106a | |||
431f299756 | |||
d8d7f5f711 | |||
a07af9fb14 | |||
f1f11f1e76 | |||
c60a6a49de | |||
6687054474 | |||
60819b3a79 | |||
3e265b4bc6 | |||
e2aa2a00f0 | |||
1edc88a2bd | |||
271e4ca07e | |||
9f79296276 |
@ -57,9 +57,10 @@ PKG_CHECK_MODULES(MUTTER_PLUGIN, gio-unix-2.0 gtk+-2.0 dbus-glib-1 mutter-plugin
|
||||
gnome-desktop-2.0 >= 2.26 libstartup-notification-1.0
|
||||
gobject-introspection-1.0 >= 0.6.5)
|
||||
PKG_CHECK_MODULES(TIDY, clutter-1.0)
|
||||
PKG_CHECK_MODULES(ST, clutter-1.0 gtk+-2.0 clutter-imcontext-0.1 libcroco-0.6)
|
||||
PKG_CHECK_MODULES(NBTK, clutter-1.0 gtk+-2.0 clutter-imcontext-0.1)
|
||||
PKG_CHECK_MODULES(BIG, clutter-1.0 gtk+-2.0 librsvg-2.0)
|
||||
PKG_CHECK_MODULES(GDMUSER, dbus-glib-1 gtk+-2.0)
|
||||
PKG_CHECK_MODULES(TOOLKIT, clutter-1.0 libcroco-0.6)
|
||||
PKG_CHECK_MODULES(TRAY, gtk+-2.0)
|
||||
|
||||
MUTTER_BIN_DIR=`$PKG_CONFIG --variable=exec_prefix mutter-plugins`/bin
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* Copyright 2009, Red Hat, Inc.
|
||||
*
|
||||
* Portions adapted from Mx's data/style/default.css
|
||||
* Portions adapted from NBTK's data/style/default.css
|
||||
* Copyright 2009 Intel Corporation
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@ -17,46 +17,46 @@
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
StScrollBar
|
||||
NbtkScrollBar
|
||||
{
|
||||
background-color: #354761;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
StScrollView
|
||||
NbtkScrollView
|
||||
{
|
||||
scrollbar-width: 16px;
|
||||
scrollbar-height: 16px;
|
||||
}
|
||||
|
||||
StButton#up-stepper
|
||||
NbtkButton#up-stepper
|
||||
{
|
||||
border-image: url("scroll-button-up.png") 5;
|
||||
}
|
||||
|
||||
StButton#up-stepper:hover,
|
||||
StButton#up-stepper:active
|
||||
NbtkButton#up-stepper:hover,
|
||||
NbtkButton#up-stepper:active
|
||||
{
|
||||
border-image: url("scroll-button-up-hover.png") 5;
|
||||
}
|
||||
|
||||
StButton#down-stepper
|
||||
NbtkButton#down-stepper
|
||||
{
|
||||
border-image: url("scroll-button-down.png") 5;
|
||||
}
|
||||
|
||||
StButton#down-stepper:hover,
|
||||
StButton#down-stepper:active
|
||||
NbtkButton#down-stepper:hover,
|
||||
NbtkButton#down-stepper:active
|
||||
{
|
||||
border-image: url("scroll-button-down-hover.png") 5;
|
||||
}
|
||||
|
||||
StScrollBar StButton#vhandle
|
||||
NbtkScrollBar NbtkButton#vhandle
|
||||
{
|
||||
border-image: url("scroll-vhandle.png") 5;
|
||||
}
|
||||
|
||||
StScrollBar StButton#vhandle:hover
|
||||
NbtkScrollBar NbtkButton#vhandle:hover
|
||||
{
|
||||
border-image: url("scroll-vhandle.png") 5;
|
||||
}
|
||||
@ -80,17 +80,17 @@ StScrollBar StButton#vhandle:hover
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
#LookingGlassDialog StLabel
|
||||
#LookingGlassDialog NbtkLabel
|
||||
{
|
||||
color: #88ff66;
|
||||
}
|
||||
|
||||
#LookingGlassDialog StEntry
|
||||
#LookingGlassDialog NbtkEntry
|
||||
{
|
||||
color: #88ff66;
|
||||
}
|
||||
|
||||
#LookingGlassDialog StBoxLayout#EvalBox
|
||||
#LookingGlassDialog NbtkBoxLayout#EvalBox
|
||||
{
|
||||
padding: 4px;
|
||||
spacing: 4px;
|
||||
|
@ -11,7 +11,6 @@ dist_jsui_DATA = \
|
||||
docDisplay.js \
|
||||
environment.js \
|
||||
genericDisplay.js \
|
||||
lightbox.js \
|
||||
link.js \
|
||||
lookingGlass.js \
|
||||
main.js \
|
||||
@ -19,7 +18,6 @@ dist_jsui_DATA = \
|
||||
panel.js \
|
||||
places.js \
|
||||
runDialog.js \
|
||||
shellDBus.js \
|
||||
sidebar.js \
|
||||
tweener.js \
|
||||
widget.js \
|
||||
|
416
js/ui/altTab.js
416
js/ui/altTab.js
@ -2,26 +2,33 @@
|
||||
|
||||
const Big = imports.gi.Big;
|
||||
const Clutter = imports.gi.Clutter;
|
||||
const Gdk = imports.gi.Gdk;
|
||||
const Lang = imports.lang;
|
||||
const Meta = imports.gi.Meta;
|
||||
const Pango = imports.gi.Pango;
|
||||
const Shell = imports.gi.Shell;
|
||||
|
||||
const AppIcon = imports.ui.appIcon;
|
||||
const Lightbox = imports.ui.lightbox;
|
||||
const Main = imports.ui.main;
|
||||
const Tweener = imports.ui.tweener;
|
||||
|
||||
const POPUP_BG_COLOR = new Clutter.Color();
|
||||
POPUP_BG_COLOR.from_pixel(0x00000080);
|
||||
const POPUP_APPICON_BORDER_COLOR = new Clutter.Color();
|
||||
POPUP_APPICON_BORDER_COLOR.from_pixel(0xffffffff);
|
||||
const POPUP_INDICATOR_COLOR = new Clutter.Color();
|
||||
POPUP_INDICATOR_COLOR.from_pixel(0xf0f0f0ff);
|
||||
const POPUP_TRANSPARENT = new Clutter.Color();
|
||||
POPUP_TRANSPARENT.from_pixel(0x00000000);
|
||||
|
||||
const POPUP_INDICATOR_WIDTH = 4;
|
||||
const POPUP_GRID_SPACING = 8;
|
||||
const POPUP_ICON_SIZE = 48;
|
||||
const POPUP_NUM_COLUMNS = 5;
|
||||
|
||||
const POPUP_POINTER_SELECTION_THRESHOLD = 3;
|
||||
const POPUP_LABEL_MAX_WIDTH = POPUP_NUM_COLUMNS * (POPUP_ICON_SIZE + POPUP_GRID_SPACING);
|
||||
|
||||
const OVERLAY_COLOR = new Clutter.Color();
|
||||
OVERLAY_COLOR.from_pixel(0x00000044);
|
||||
|
||||
const SHOW_TIME = 0.05;
|
||||
const SWITCH_TIME = 0.1;
|
||||
|
||||
function AltTabPopup() {
|
||||
this._init();
|
||||
@ -33,9 +40,7 @@ AltTabPopup.prototype = {
|
||||
corner_radius: POPUP_GRID_SPACING,
|
||||
padding: POPUP_GRID_SPACING,
|
||||
spacing: POPUP_GRID_SPACING,
|
||||
orientation: Big.BoxOrientation.VERTICAL,
|
||||
reactive: true });
|
||||
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
|
||||
orientation: Big.BoxOrientation.VERTICAL });
|
||||
|
||||
// Icon grid. TODO: Investigate Nbtk.Grid once that lands. Currently
|
||||
// just implemented using a chain of Big.Box.
|
||||
@ -46,31 +51,82 @@ AltTabPopup.prototype = {
|
||||
gcenterbox.append(this._grid, Big.BoxPackFlags.NONE);
|
||||
this.actor.append(gcenterbox, Big.BoxPackFlags.NONE);
|
||||
|
||||
this._icons = [];
|
||||
this._currentWindows = [];
|
||||
this._haveModal = false;
|
||||
this._selected = 0;
|
||||
this._highlightedWindow = null;
|
||||
// Selected-window label
|
||||
this._label = new Clutter.Text({ font_name: "Sans 16px",
|
||||
ellipsize: Pango.EllipsizeMode.END });
|
||||
|
||||
let labelbox = new Big.Box({ background_color: POPUP_INDICATOR_COLOR,
|
||||
corner_radius: POPUP_GRID_SPACING / 2,
|
||||
padding: POPUP_GRID_SPACING / 2 });
|
||||
labelbox.append(this._label, Big.BoxPackFlags.NONE);
|
||||
let lcenterbox = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL,
|
||||
x_align: Big.BoxAlignment.CENTER,
|
||||
width: POPUP_LABEL_MAX_WIDTH + POPUP_GRID_SPACING });
|
||||
lcenterbox.append(labelbox, Big.BoxPackFlags.NONE);
|
||||
this.actor.append(lcenterbox, Big.BoxPackFlags.NONE);
|
||||
|
||||
// Indicator around selected icon
|
||||
this._indicator = new Big.Rectangle({ border_width: POPUP_INDICATOR_WIDTH,
|
||||
corner_radius: POPUP_INDICATOR_WIDTH / 2,
|
||||
border_color: POPUP_INDICATOR_COLOR,
|
||||
color: POPUP_TRANSPARENT });
|
||||
this.actor.append(this._indicator, Big.BoxPackFlags.FIXED);
|
||||
|
||||
this._items = [];
|
||||
this._toplevels = global.window_group.get_children();
|
||||
|
||||
global.stage.add_actor(this.actor);
|
||||
|
||||
// Dark translucent window used to cover all but the
|
||||
// currently-selected window while Alt-Tabbing. Actually
|
||||
// contains four actors which can we rearrange to create
|
||||
// a hole in the overlay.
|
||||
this._overlay = new Clutter.Group({ reactive: true });
|
||||
this._overlay_top = new Clutter.Rectangle({ color: OVERLAY_COLOR,
|
||||
border_width: 0 });
|
||||
this._overlay_bottom = new Clutter.Rectangle({ color: OVERLAY_COLOR,
|
||||
border_width: 0 });
|
||||
this._overlay_left = new Clutter.Rectangle({ color: OVERLAY_COLOR,
|
||||
border_width: 0 });
|
||||
this._overlay_right = new Clutter.Rectangle({ color: OVERLAY_COLOR,
|
||||
border_width: 0 });
|
||||
this._overlay.add_actor(this._overlay_top);
|
||||
this._overlay.add_actor(this._overlay_bottom);
|
||||
this._overlay.add_actor(this._overlay_left);
|
||||
this._overlay.add_actor(this._overlay_right);
|
||||
},
|
||||
|
||||
_addIcon : function(appIcon) {
|
||||
appIcon.connect('activate', Lang.bind(this, this._appClicked));
|
||||
appIcon.connect('activate-window', Lang.bind(this, this._windowClicked));
|
||||
appIcon.connect('highlight-window', Lang.bind(this, this._windowHovered));
|
||||
appIcon.connect('menu-popped-up', Lang.bind(this, this._menuPoppedUp));
|
||||
appIcon.connect('menu-popped-down', Lang.bind(this, this._menuPoppedDown));
|
||||
addWindow : function(win) {
|
||||
let item = { window: win,
|
||||
metaWindow: win.get_meta_window() };
|
||||
|
||||
appIcon.actor.connect('enter-event', Lang.bind(this, this._iconEntered));
|
||||
let pixbuf = item.metaWindow.icon;
|
||||
item.icon = new Clutter.Texture({ width: POPUP_ICON_SIZE,
|
||||
height: POPUP_ICON_SIZE,
|
||||
keep_aspect_ratio: true });
|
||||
Shell.clutter_texture_set_from_pixbuf(item.icon, pixbuf);
|
||||
|
||||
// FIXME?
|
||||
appIcon.actor.border = 2;
|
||||
appIcon.highlight_border_color = POPUP_APPICON_BORDER_COLOR;
|
||||
item.box = new Big.Box({ padding: POPUP_INDICATOR_WIDTH * 2 });
|
||||
item.box.append(item.icon, Big.BoxPackFlags.NONE);
|
||||
|
||||
this._icons.push(appIcon);
|
||||
this._currentWindows.push(appIcon.windows[0]);
|
||||
item.above = null;
|
||||
for (let i = 1; i < this._toplevels.length; i++) {
|
||||
if (this._toplevels[i] == win) {
|
||||
item.above = this._toplevels[i - 1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
item.visible = item.metaWindow.showing_on_its_workspace();
|
||||
|
||||
if (!item.visible) {
|
||||
let rect = new Meta.Rectangle();
|
||||
if (item.metaWindow.get_icon_geometry(rect))
|
||||
item.icon_rect = rect;
|
||||
}
|
||||
|
||||
item.n = this._items.length;
|
||||
this._items.push(item);
|
||||
|
||||
// Add it to the grid
|
||||
if (!this._gridRow || this._gridRow.get_children().length == POPUP_NUM_COLUMNS) {
|
||||
@ -78,210 +134,146 @@ AltTabPopup.prototype = {
|
||||
orientation: Big.BoxOrientation.HORIZONTAL });
|
||||
this._grid.append(this._gridRow, Big.BoxPackFlags.NONE);
|
||||
}
|
||||
this._gridRow.append(appIcon.actor, Big.BoxPackFlags.NONE);
|
||||
this._gridRow.append(item.box, Big.BoxPackFlags.NONE);
|
||||
},
|
||||
|
||||
show : function(initialSelection) {
|
||||
let appMonitor = Shell.AppMonitor.get_default();
|
||||
let apps = appMonitor.get_running_apps ("");
|
||||
|
||||
if (!apps.length)
|
||||
return false;
|
||||
|
||||
if (!Main.pushModal(this.actor))
|
||||
return false;
|
||||
this._haveModal = true;
|
||||
|
||||
this._keyPressEventId = global.stage.connect('key-press-event', Lang.bind(this, this._keyPressEvent));
|
||||
this._keyReleaseEventId = global.stage.connect('key-release-event', Lang.bind(this, this._keyReleaseEvent));
|
||||
|
||||
this._motionEventId = this.actor.connect('motion-event', Lang.bind(this, this._mouseMoved));
|
||||
this._mouseActive = false;
|
||||
this._mouseMovement = 0;
|
||||
|
||||
// Contruct the AppIcons, sort by time, add to the popup
|
||||
let icons = [];
|
||||
for (let i = 0; i < apps.length; i++)
|
||||
icons.push(new AppIcon.AppIcon(apps[i], AppIcon.MenuType.BELOW));
|
||||
icons.sort(Lang.bind(this, this._sortAppIcon));
|
||||
for (let i = 0; i < icons.length; i++)
|
||||
this._addIcon(icons[i]);
|
||||
|
||||
// Need to specify explicit width and height because the
|
||||
// window_group may not actually cover the whole screen
|
||||
this._lightbox = new Lightbox.Lightbox(global.window_group,
|
||||
global.screen_width,
|
||||
global.screen_height);
|
||||
global.window_group.add_actor(this._overlay);
|
||||
this._overlay.raise_top();
|
||||
this._overlay.show();
|
||||
this.actor.opacity = 0;
|
||||
Tweener.addTween(this.actor, { opacity: 255,
|
||||
time: SHOW_TIME,
|
||||
transition: "easeOutQuad" });
|
||||
|
||||
this.actor.show_all();
|
||||
this.actor.x = Math.floor((global.screen_width - this.actor.width) / 2);
|
||||
this.actor.y = Math.floor((global.screen_height - this.actor.height) / 2);
|
||||
|
||||
this._updateSelection(initialSelection);
|
||||
|
||||
// There's a race condition; if the user released Alt before
|
||||
// we got the grab, then we won't be notified. (See
|
||||
// https://bugzilla.gnome.org/show_bug.cgi?id=596695 for
|
||||
// details.) So we check now. (Have to do this after calling
|
||||
// _updateSelection.)
|
||||
let [screen, x, y, mods] = Gdk.Display.get_default().get_pointer();
|
||||
if (!(mods & Gdk.ModifierType.MOD1_MASK)) {
|
||||
this._finish();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
_hasVisibleWindows : function(appIcon) {
|
||||
for (let i = 0; i < appIcon.windows.length; i++) {
|
||||
if (appIcon.windows[i].showing_on_its_workspace())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
_sortAppIcon : function(appIcon1, appIcon2) {
|
||||
let vis1 = this._hasVisibleWindows(appIcon1);
|
||||
let vis2 = this._hasVisibleWindows(appIcon2);
|
||||
|
||||
if (vis1 && !vis2) {
|
||||
return -1;
|
||||
} else if (vis2 && !vis1) {
|
||||
return 1;
|
||||
} else {
|
||||
// The app's most-recently-used window is first
|
||||
// in its list
|
||||
return (appIcon2.windows[0].get_user_time() -
|
||||
appIcon1.windows[0].get_user_time());
|
||||
}
|
||||
},
|
||||
|
||||
_keyPressEvent : function(actor, event) {
|
||||
let keysym = event.get_key_symbol();
|
||||
let backwards = (event.get_state() & Clutter.ModifierType.SHIFT_MASK);
|
||||
|
||||
if (keysym == Clutter.Tab)
|
||||
this._updateSelection(backwards ? -1 : 1);
|
||||
else if (keysym == Clutter.grave)
|
||||
this._updateWindowSelection(backwards ? -1 : 1);
|
||||
else if (keysym == Clutter.Escape)
|
||||
this.destroy();
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
_keyReleaseEvent : function(actor, event) {
|
||||
let keysym = event.get_key_symbol();
|
||||
|
||||
if (keysym == Clutter.Alt_L || keysym == Clutter.Alt_R)
|
||||
this._finish();
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
_appClicked : function(icon) {
|
||||
Main.activateWindow(icon.windows[0]);
|
||||
this.destroy();
|
||||
},
|
||||
|
||||
_windowClicked : function(icon, window) {
|
||||
if (window)
|
||||
Main.activateWindow(window);
|
||||
this.destroy();
|
||||
},
|
||||
|
||||
_windowHovered : function(icon, window) {
|
||||
if (window)
|
||||
this._highlightWindow(window);
|
||||
},
|
||||
|
||||
_mouseMoved : function(actor, event) {
|
||||
if (++this._mouseMovement < POPUP_POINTER_SELECTION_THRESHOLD)
|
||||
return;
|
||||
|
||||
this.actor.disconnect(this._motionEventId);
|
||||
this._mouseActive = true;
|
||||
|
||||
actor = event.get_source();
|
||||
while (actor) {
|
||||
if (actor._delegate instanceof AppIcon.AppIcon) {
|
||||
this._iconEntered(actor, event);
|
||||
return;
|
||||
}
|
||||
actor = actor.get_parent();
|
||||
}
|
||||
},
|
||||
|
||||
_iconEntered : function(actor, event) {
|
||||
let index = this._icons.indexOf(actor._delegate);
|
||||
if (this._mouseActive)
|
||||
this._updateSelection(index - this._selected);
|
||||
},
|
||||
|
||||
_finish : function() {
|
||||
if (this._highlightedWindow)
|
||||
Main.activateWindow(this._highlightedWindow);
|
||||
this.destroy();
|
||||
this.select(initialSelection);
|
||||
},
|
||||
|
||||
destroy : function() {
|
||||
this.actor.destroy();
|
||||
this._overlay.destroy();
|
||||
},
|
||||
|
||||
_onDestroy : function() {
|
||||
if (this._haveModal)
|
||||
Main.popModal(this.actor);
|
||||
select : function(n) {
|
||||
if (this._selected) {
|
||||
// Unselect previous
|
||||
|
||||
if (this._lightbox)
|
||||
this._lightbox.destroy();
|
||||
|
||||
if (this._keyPressEventId)
|
||||
global.stage.disconnect(this._keyPressEventId);
|
||||
if (this._keyReleaseEventId)
|
||||
global.stage.disconnect(this._keyReleaseEventId);
|
||||
},
|
||||
|
||||
_updateSelection : function(delta) {
|
||||
this._icons[this._selected].setHighlight(false);
|
||||
if (delta != 0 && this._selectedMenu)
|
||||
this._selectedMenu.popdown();
|
||||
|
||||
this._selected = (this._selected + this._icons.length + delta) % this._icons.length;
|
||||
this._icons[this._selected].setHighlight(true);
|
||||
|
||||
this._highlightWindow(this._currentWindows[this._selected]);
|
||||
},
|
||||
|
||||
_menuPoppedUp : function(icon, menu) {
|
||||
this._selectedMenu = menu;
|
||||
},
|
||||
|
||||
_menuPoppedDown : function(icon, menu) {
|
||||
this._selectedMenu = null;
|
||||
},
|
||||
|
||||
_updateWindowSelection : function(delta) {
|
||||
let icon = this._icons[this._selected];
|
||||
|
||||
if (!this._selectedMenu)
|
||||
icon.popupMenu();
|
||||
if (!this._selectedMenu)
|
||||
return;
|
||||
|
||||
let next = 0;
|
||||
for (let i = 0; i < icon.windows.length; i++) {
|
||||
if (icon.windows[i] == this._highlightedWindow) {
|
||||
next = (i + icon.windows.length + delta) % icon.windows.length;
|
||||
break;
|
||||
if (this._allocationChangedId) {
|
||||
this._selected.box.disconnect(this._allocationChangedId);
|
||||
delete this._allocationChangedId;
|
||||
}
|
||||
|
||||
if (this._selected.above)
|
||||
this._selected.window.raise(this._selected.above);
|
||||
else
|
||||
this._selected.window.lower_bottom();
|
||||
}
|
||||
|
||||
let item = this._items[n];
|
||||
let changed = this._selected && item != this._selected;
|
||||
this._selected = item;
|
||||
|
||||
if (this._selected) {
|
||||
this._label.set_size(-1, -1);
|
||||
this._label.text = this._selected.metaWindow.title;
|
||||
if (this._label.width > POPUP_LABEL_MAX_WIDTH)
|
||||
this._label.width = POPUP_LABEL_MAX_WIDTH;
|
||||
|
||||
// Figure out this._selected.box's coordinates in terms of
|
||||
// this.actor
|
||||
let bx = this._selected.box.x, by = this._selected.box.y;
|
||||
let actor = this._selected.box.get_parent();
|
||||
while (actor != this.actor) {
|
||||
bx += actor.x;
|
||||
by += actor.y;
|
||||
actor = actor.get_parent();
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
Tweener.addTween(this._indicator,
|
||||
{ x: bx,
|
||||
y: by,
|
||||
width: this._selected.box.width,
|
||||
height: this._selected.box.height,
|
||||
time: SWITCH_TIME,
|
||||
transition: "easeOutQuad" });
|
||||
} else {
|
||||
Tweener.removeTweens(this.indicator);
|
||||
this._indicator.set_position(bx, by);
|
||||
this._indicator.set_size(this._selected.box.width,
|
||||
this._selected.box.height);
|
||||
}
|
||||
this._indicator.show();
|
||||
|
||||
if (this._overlay.visible) {
|
||||
if (this._selected.visible)
|
||||
this._selected.window.raise(this._overlay);
|
||||
this._adjust_overlay();
|
||||
}
|
||||
|
||||
this._allocationChangedId =
|
||||
this._selected.box.connect('notify::allocation',
|
||||
Lang.bind(this, this._allocationChanged));
|
||||
} else {
|
||||
this._label.text = "";
|
||||
this._indicator.hide();
|
||||
}
|
||||
this._selectedMenu.selectWindow(icon.windows[next]);
|
||||
},
|
||||
|
||||
_highlightWindow : function(metaWin) {
|
||||
this._highlightedWindow = metaWin;
|
||||
this._currentWindows[this._selected] = metaWin;
|
||||
this._lightbox.highlight(this._highlightedWindow.get_compositor_private());
|
||||
_allocationChanged : function() {
|
||||
if (this._selected)
|
||||
this.select(this._selected.n);
|
||||
},
|
||||
|
||||
_adjust_overlay : function() {
|
||||
if (this._selected && this._selected.icon_rect) {
|
||||
// We want to highlight a specific rectangle within the
|
||||
// task bar, so rearrange the pieces of the overlay to
|
||||
// cover the whole screen except that rectangle
|
||||
|
||||
let rect = this._selected.icon_rect;
|
||||
|
||||
this._overlay_top.x = 0;
|
||||
this._overlay_top.y = 0;
|
||||
this._overlay_top.width = global.screen_width;
|
||||
this._overlay_top.height = rect.y;
|
||||
|
||||
this._overlay_left.x = 0;
|
||||
this._overlay_left.y = rect.y;
|
||||
this._overlay_left.width = rect.x;
|
||||
this._overlay_left.height = rect.height;
|
||||
this._overlay_left.show();
|
||||
|
||||
this._overlay_right.x = rect.x + rect.width;
|
||||
this._overlay_right.y = rect.y;
|
||||
this._overlay_right.width = global.screen_width - rect.x - rect.width;
|
||||
this._overlay_right.height = rect.height;
|
||||
this._overlay_right.show();
|
||||
|
||||
this._overlay_bottom.x = 0;
|
||||
this._overlay_bottom.y = rect.y + rect.height;
|
||||
this._overlay_bottom.width = global.screen_width;
|
||||
this._overlay_bottom.height = global.screen_height - rect.y - rect.height;
|
||||
this._overlay_bottom.show();
|
||||
} else {
|
||||
// Either there's no current selection, or the selection
|
||||
// is a visible window. Make the overlay cover the whole
|
||||
// screen. select() will raise the selected window over
|
||||
// the overlay.
|
||||
|
||||
this._overlay_top.x = 0;
|
||||
this._overlay_top.y = 0;
|
||||
this._overlay_top.width = global.screen_width;
|
||||
this._overlay_top.height = global.screen_height;
|
||||
this._overlay_top.show();
|
||||
|
||||
this._overlay_left.hide();
|
||||
this._overlay_right.hide();
|
||||
this._overlay_bottom.hide();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -23,11 +23,32 @@ const ENTERED_MENU_COLOR = new Clutter.Color();
|
||||
ENTERED_MENU_COLOR.from_pixel(0x00ff0022);
|
||||
|
||||
const WELL_DEFAULT_COLUMNS = 4;
|
||||
const WELL_ITEM_MIN_HSPACING = 4;
|
||||
const WELL_ITEM_HSPACING = 0;
|
||||
const WELL_ITEM_VSPACING = 4;
|
||||
|
||||
const MENU_ARROW_SIZE = 12;
|
||||
const MENU_SPACING = 7;
|
||||
const WELL_MENU_POPUP_TIMEOUT_MS = 600;
|
||||
|
||||
const TRANSPARENT_COLOR = new Clutter.Color();
|
||||
TRANSPARENT_COLOR.from_pixel(0x00000000);
|
||||
|
||||
const WELL_MENU_BACKGROUND_COLOR = new Clutter.Color();
|
||||
WELL_MENU_BACKGROUND_COLOR.from_pixel(0x292929ff);
|
||||
const WELL_MENU_FONT = 'Sans 14px';
|
||||
const WELL_MENU_COLOR = new Clutter.Color();
|
||||
WELL_MENU_COLOR.from_pixel(0xffffffff);
|
||||
const WELL_MENU_SELECTED_COLOR = new Clutter.Color();
|
||||
WELL_MENU_SELECTED_COLOR.from_pixel(0x005b97ff);
|
||||
const WELL_MENU_BORDER_COLOR = new Clutter.Color();
|
||||
WELL_MENU_BORDER_COLOR.from_pixel(0x787878ff);
|
||||
const WELL_MENU_SEPARATOR_COLOR = new Clutter.Color();
|
||||
WELL_MENU_SEPARATOR_COLOR.from_pixel(0x787878ff);
|
||||
const WELL_MENU_BORDER_WIDTH = 1;
|
||||
const WELL_MENU_ARROW_SIZE = 12;
|
||||
const WELL_MENU_CORNER_RADIUS = 4;
|
||||
const WELL_MENU_PADDING = 4;
|
||||
|
||||
const MENU_ICON_SIZE = 24;
|
||||
const MENU_SPACING = 15;
|
||||
|
||||
const MAX_ITEMS = 30;
|
||||
|
||||
@ -60,7 +81,7 @@ AppDisplayItem.prototype = {
|
||||
let windows = Shell.AppMonitor.get_default().get_windows_for_app(this._appInfo.get_id());
|
||||
if (windows.length > 0) {
|
||||
let mostRecentWindow = windows[0];
|
||||
Main.overview.activateWindow(mostRecentWindow, Main.currentTime());
|
||||
Main.overview.activateWindow(mostRecentWindow, Clutter.get_current_event_time());
|
||||
} else {
|
||||
this._appInfo.launch();
|
||||
}
|
||||
@ -87,8 +108,8 @@ const MENU_UNSELECTED = 0;
|
||||
const MENU_SELECTED = 1;
|
||||
const MENU_ENTERED = 2;
|
||||
|
||||
function MenuItem(name, id) {
|
||||
this._init(name, id);
|
||||
function MenuItem(name, id, iconName) {
|
||||
this._init(name, id, iconName);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,19 +117,31 @@ function MenuItem(name, id) {
|
||||
* Shows the list of menus in the sidebar.
|
||||
*/
|
||||
MenuItem.prototype = {
|
||||
_init: function(name, id) {
|
||||
_init: function(name, id, iconName) {
|
||||
this.id = id;
|
||||
|
||||
this.actor = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL,
|
||||
spacing: 4,
|
||||
corner_radius: 4,
|
||||
padding_right: 4,
|
||||
padding_left: 4,
|
||||
reactive: true });
|
||||
this.actor.connect('button-press-event', Lang.bind(this, function (a, e) {
|
||||
this.setState(MENU_SELECTED);
|
||||
}));
|
||||
|
||||
let iconTheme = Gtk.IconTheme.get_default();
|
||||
let pixbuf = null;
|
||||
this._icon = new Clutter.Texture({ width: MENU_ICON_SIZE,
|
||||
height: MENU_ICON_SIZE });
|
||||
// Wine manages not to have an icon
|
||||
try {
|
||||
pixbuf = iconTheme.load_icon(iconName, MENU_ICON_SIZE, 0 /* flags */);
|
||||
} catch (e) {
|
||||
pixbuf = iconTheme.load_icon('gtk-file', MENU_ICON_SIZE, 0);
|
||||
}
|
||||
if (pixbuf != null)
|
||||
Shell.clutter_texture_set_from_pixbuf(this._icon, pixbuf);
|
||||
this.actor.append(this._icon, Big.BoxPackFlags.NONE);
|
||||
this._text = new Clutter.Text({ color: GenericDisplay.ITEM_DISPLAY_NAME_COLOR,
|
||||
font_name: "Sans 14px",
|
||||
text: name });
|
||||
@ -116,8 +149,7 @@ MenuItem.prototype = {
|
||||
// We use individual boxes for the label and the arrow to ensure that they
|
||||
// are aligned vertically. Just setting y_align: Big.BoxAlignment.CENTER
|
||||
// on this.actor does not seem to achieve that.
|
||||
let labelBox = new Big.Box({ y_align: Big.BoxAlignment.CENTER,
|
||||
padding: 4 });
|
||||
let labelBox = new Big.Box({ y_align: Big.BoxAlignment.CENTER });
|
||||
|
||||
labelBox.append(this._text, Big.BoxPackFlags.NONE);
|
||||
|
||||
@ -125,8 +157,8 @@ MenuItem.prototype = {
|
||||
|
||||
let arrowBox = new Big.Box({ y_align: Big.BoxAlignment.CENTER });
|
||||
|
||||
this._arrow = new Shell.Arrow({ surface_width: MENU_ARROW_SIZE,
|
||||
surface_height: MENU_ARROW_SIZE,
|
||||
this._arrow = new Shell.Arrow({ surface_width: MENU_ICON_SIZE / 2,
|
||||
surface_height: MENU_ICON_SIZE / 2,
|
||||
direction: Gtk.ArrowType.RIGHT,
|
||||
opacity: 0 });
|
||||
arrowBox.append(this._arrow, Big.BoxPackFlags.NONE);
|
||||
@ -186,17 +218,17 @@ AppDisplay.prototype = {
|
||||
this._appsStale = true;
|
||||
this._appSystem.connect('installed-changed', Lang.bind(this, function(appSys) {
|
||||
this._appsStale = true;
|
||||
this._redisplay(0);
|
||||
this._redisplay(false);
|
||||
this._redisplayMenus();
|
||||
}));
|
||||
this._appSystem.connect('favorites-changed', Lang.bind(this, function(appSys) {
|
||||
this._redisplay(0);
|
||||
this._redisplay(false);
|
||||
}));
|
||||
this._appMonitor.connect('app-added', Lang.bind(this, function(monitor) {
|
||||
this._redisplay(0);
|
||||
this._redisplay(false);
|
||||
}));
|
||||
this._appMonitor.connect('app-removed', Lang.bind(this, function(monitor) {
|
||||
this._redisplay(0);
|
||||
this._redisplay(false);
|
||||
}));
|
||||
|
||||
// Load the apps now so it doesn't slow down the first
|
||||
@ -284,8 +316,8 @@ AppDisplay.prototype = {
|
||||
})).filter(function (e) { return e != null });
|
||||
},
|
||||
|
||||
_addMenuItem: function(name, id, index) {
|
||||
let display = new MenuItem(name, id);
|
||||
_addMenuItem: function(name, id, icon, index) {
|
||||
let display = new MenuItem(name, id, icon);
|
||||
this._menuDisplays.push(display);
|
||||
display.connect('state-changed', Lang.bind(this, function (display) {
|
||||
let activated = display.getState() != MENU_UNSELECTED;
|
||||
@ -311,13 +343,9 @@ AppDisplay.prototype = {
|
||||
_redisplayMenus: function() {
|
||||
this._menuDisplay.remove_all();
|
||||
this._addMenuItem(_("Frequent"), null, 'gtk-select-all');
|
||||
// Adding an empty box here results in double spacing between
|
||||
// "Frequent" and the other items.
|
||||
let separator_actor = new Big.Box();
|
||||
this._menuDisplay.append(separator_actor, 0);
|
||||
for (let i = 0; i < this._menus.length; i++) {
|
||||
let menu = this._menus[i];
|
||||
this._addMenuItem(menu.name, menu.id, i+1);
|
||||
this._addMenuItem(menu.name, menu.id, menu.icon, i+1);
|
||||
}
|
||||
},
|
||||
|
||||
@ -331,7 +359,7 @@ AppDisplay.prototype = {
|
||||
// Gets information about all applications by calling Gio.app_info_get_all().
|
||||
_refreshCache : function() {
|
||||
if (!this._appsStale)
|
||||
return true;
|
||||
return;
|
||||
this._allItems = {};
|
||||
this._appCategories = {};
|
||||
|
||||
@ -364,13 +392,11 @@ AppDisplay.prototype = {
|
||||
}
|
||||
|
||||
this._appsStale = false;
|
||||
return false;
|
||||
},
|
||||
|
||||
// Stub this out; the app display always has a category selected
|
||||
_setDefaultList : function() {
|
||||
this._matchedItems = {};
|
||||
this._matchedItemKeys = [];
|
||||
this._matchedItems = [];
|
||||
},
|
||||
|
||||
// Compares items associated with the item ids based on the alphabetical order
|
||||
@ -454,19 +480,264 @@ AppDisplay.prototype = {
|
||||
|
||||
Signals.addSignalMethods(AppDisplay.prototype);
|
||||
|
||||
function BaseWellItem(appInfo, isFavorite, hasMenu) {
|
||||
this._init(appInfo, isFavorite, hasMenu);
|
||||
function WellMenu(source) {
|
||||
this._init(source);
|
||||
}
|
||||
|
||||
WellMenu.prototype = {
|
||||
_init: function(source) {
|
||||
this._source = source;
|
||||
|
||||
// Whether or not we successfully picked a window
|
||||
this.didActivateWindow = false;
|
||||
|
||||
this.actor = new Shell.GenericContainer({ reactive: true });
|
||||
this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
|
||||
this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
|
||||
this.actor.connect('allocate', Lang.bind(this, this._allocate));
|
||||
|
||||
this._windowContainer = new Shell.Menu({ orientation: Big.BoxOrientation.VERTICAL,
|
||||
border_color: WELL_MENU_BORDER_COLOR,
|
||||
border: WELL_MENU_BORDER_WIDTH,
|
||||
background_color: WELL_MENU_BACKGROUND_COLOR,
|
||||
padding: 4,
|
||||
corner_radius: WELL_MENU_CORNER_RADIUS,
|
||||
width: Main.overview._dash.actor.width * 0.75 });
|
||||
this._windowContainer.connect('unselected', Lang.bind(this, this._onWindowUnselected));
|
||||
this._windowContainer.connect('selected', Lang.bind(this, this._onWindowSelected));
|
||||
this._windowContainer.connect('cancelled', Lang.bind(this, this._onWindowSelectionCancelled));
|
||||
this._windowContainer.connect('activate', Lang.bind(this, this._onWindowActivate));
|
||||
this.actor.add_actor(this._windowContainer);
|
||||
|
||||
// Stay popped up on release over application icon
|
||||
this._windowContainer.set_persistent_source(this._source.actor);
|
||||
|
||||
// Intercept events while the menu has the pointer grab to do window-related effects
|
||||
this._windowContainer.connect('enter-event', Lang.bind(this, this._onMenuEnter));
|
||||
this._windowContainer.connect('leave-event', Lang.bind(this, this._onMenuLeave));
|
||||
this._windowContainer.connect('button-release-event', Lang.bind(this, this._onMenuButtonRelease));
|
||||
|
||||
this._arrow = new Shell.DrawingArea();
|
||||
this._arrow.connect('redraw', Lang.bind(this, function (area, texture) {
|
||||
Shell.draw_box_pointer(texture, WELL_MENU_BORDER_COLOR, WELL_MENU_BACKGROUND_COLOR);
|
||||
}));
|
||||
this.actor.add_actor(this._arrow);
|
||||
|
||||
// Chain our visibility and lifecycle to that of the source
|
||||
source.actor.connect('notify::mapped', Lang.bind(this, function () {
|
||||
if (!source.actor.mapped)
|
||||
this._windowContainer.popdown();
|
||||
}));
|
||||
source.actor.connect('destroy', Lang.bind(this, function () { this.actor.destroy(); }));
|
||||
|
||||
global.stage.add_actor(this.actor);
|
||||
},
|
||||
|
||||
_getPreferredWidth: function(actor, forHeight, alloc) {
|
||||
let [min, natural] = this._windowContainer.get_preferred_width(forHeight);
|
||||
alloc.min_size = min + WELL_MENU_ARROW_SIZE;
|
||||
alloc.natural_size = natural + WELL_MENU_ARROW_SIZE;
|
||||
},
|
||||
|
||||
_getPreferredHeight: function(actor, forWidth, alloc) {
|
||||
let [min, natural] = this._windowContainer.get_preferred_height(forWidth);
|
||||
alloc.min_size = min;
|
||||
alloc.natural_size = natural;
|
||||
},
|
||||
|
||||
_allocate: function(actor, box, flags) {
|
||||
let childBox = new Clutter.ActorBox();
|
||||
|
||||
let width = box.x2 - box.x1;
|
||||
let height = box.y2 - box.y1;
|
||||
|
||||
childBox.x1 = 0;
|
||||
childBox.x2 = WELL_MENU_ARROW_SIZE;
|
||||
childBox.y1 = Math.floor((height / 2) - (WELL_MENU_ARROW_SIZE / 2));
|
||||
childBox.y2 = childBox.y1 + WELL_MENU_ARROW_SIZE;
|
||||
this._arrow.allocate(childBox, flags);
|
||||
|
||||
/* overlap by one pixel to hide the border */
|
||||
childBox.x1 = WELL_MENU_ARROW_SIZE - 1;
|
||||
childBox.x2 = width;
|
||||
childBox.y1 = 0;
|
||||
childBox.y2 = height;
|
||||
this._windowContainer.allocate(childBox, flags);
|
||||
},
|
||||
|
||||
_redisplay: function() {
|
||||
this._windowContainer.remove_all();
|
||||
|
||||
this.didActivateWindow = false;
|
||||
|
||||
let windows = this._source.windows;
|
||||
|
||||
this._windowContainer.show();
|
||||
|
||||
let iconsDiffer = false;
|
||||
let texCache = Shell.TextureCache.get_default();
|
||||
let firstIcon = windows[0].mini_icon;
|
||||
for (let i = 1; i < windows.length; i++) {
|
||||
if (!texCache.pixbuf_equal(windows[i].mini_icon, firstIcon)) {
|
||||
iconsDiffer = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let activeWorkspace = global.screen.get_active_workspace();
|
||||
|
||||
let currentWorkspaceWindows = windows.filter(function (w) {
|
||||
return w.get_workspace() == activeWorkspace;
|
||||
});
|
||||
let otherWorkspaceWindows = windows.filter(function (w) {
|
||||
return w.get_workspace() != activeWorkspace;
|
||||
});
|
||||
|
||||
this._appendWindows(currentWorkspaceWindows, iconsDiffer);
|
||||
if (currentWorkspaceWindows.length > 0 && otherWorkspaceWindows.length > 0) {
|
||||
let box = new Big.Box({ padding_top: 2, padding_bottom: 2 });
|
||||
box.append(new Clutter.Rectangle({ height: 1,
|
||||
color: WELL_MENU_SEPARATOR_COLOR }),
|
||||
Big.BoxPackFlags.EXPAND);
|
||||
this._windowContainer.append_separator(box, Big.BoxPackFlags.NONE);
|
||||
}
|
||||
this._appendWindows(otherWorkspaceWindows, iconsDiffer);
|
||||
},
|
||||
|
||||
_appendWindows: function (windows, iconsDiffer) {
|
||||
for (let i = 0; i < windows.length; i++) {
|
||||
let metaWindow = windows[i];
|
||||
|
||||
/* Use padding here rather than spacing in the box above so that
|
||||
* we have a larger reactive area.
|
||||
*/
|
||||
let box = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL,
|
||||
padding_top: 4,
|
||||
padding_bottom: 4,
|
||||
spacing: 4,
|
||||
reactive: true });
|
||||
box._window = metaWindow;
|
||||
let vCenter;
|
||||
if (iconsDiffer) {
|
||||
vCenter = new Big.Box({ y_align: Big.BoxAlignment.CENTER });
|
||||
let icon = Shell.TextureCache.get_default().bind_pixbuf_property(metaWindow, "mini-icon");
|
||||
vCenter.append(icon, Big.BoxPackFlags.NONE);
|
||||
box.append(vCenter, Big.BoxPackFlags.NONE);
|
||||
}
|
||||
vCenter = new Big.Box({ y_align: Big.BoxAlignment.CENTER });
|
||||
let label = new Clutter.Text({ text: metaWindow.title,
|
||||
font_name: WELL_MENU_FONT,
|
||||
ellipsize: Pango.EllipsizeMode.END,
|
||||
color: WELL_MENU_COLOR });
|
||||
vCenter.append(label, Big.BoxPackFlags.NONE);
|
||||
box.append(vCenter, Big.BoxPackFlags.NONE);
|
||||
this._windowContainer.append(box, Big.BoxPackFlags.NONE);
|
||||
}
|
||||
},
|
||||
|
||||
popup: function() {
|
||||
let [stageX, stageY] = this._source.actor.get_transformed_position();
|
||||
let [stageWidth, stageHeight] = this._source.actor.get_transformed_size();
|
||||
|
||||
this._redisplay();
|
||||
|
||||
this._windowContainer.popup(0, Clutter.get_current_event_time());
|
||||
|
||||
this.emit('popup', true);
|
||||
|
||||
let x = Math.floor(stageX + stageWidth);
|
||||
let y = Math.floor(stageY + (stageHeight / 2) - (this.actor.height / 2));
|
||||
this.actor.set_position(x, y);
|
||||
this.actor.show();
|
||||
},
|
||||
|
||||
_findWindowCloneForActor: function (actor) {
|
||||
if (actor._delegate instanceof Workspaces.WindowClone)
|
||||
return actor._delegate;
|
||||
return null;
|
||||
},
|
||||
|
||||
// This function is called while the menu has a pointer grab; what we want
|
||||
// to do is see if the mouse was released over a window clone actor
|
||||
_onMenuButtonRelease: function (actor, event) {
|
||||
let clone = this._findWindowCloneForActor(event.get_source());
|
||||
if (clone) {
|
||||
this.didActivateWindow = true;
|
||||
Main.overview.activateWindow(clone.metaWindow, event.get_time());
|
||||
}
|
||||
},
|
||||
|
||||
_setHighlightWindow: function (metaWindow) {
|
||||
let children = this._windowContainer.get_children();
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
let child = children[i];
|
||||
let menuMetaWindow = child._window;
|
||||
if (metaWindow != null && menuMetaWindow == metaWindow) {
|
||||
child.background_color = WELL_MENU_SELECTED_COLOR;
|
||||
} else {
|
||||
child.background_color = TRANSPARENT_COLOR;
|
||||
}
|
||||
}
|
||||
this.emit('highlight-window', metaWindow);
|
||||
},
|
||||
|
||||
// Called while menu has a pointer grab
|
||||
_onMenuEnter: function (actor, event) {
|
||||
let clone = this._findWindowCloneForActor(event.get_source());
|
||||
if (clone) {
|
||||
this._setHighlightWindow(clone.metaWindow);
|
||||
}
|
||||
},
|
||||
|
||||
// Called while menu has a pointer grab
|
||||
_onMenuLeave: function (actor, event) {
|
||||
let clone = this._findWindowCloneForActor(event.get_source());
|
||||
if (clone) {
|
||||
this._setHighlightWindow(null);
|
||||
}
|
||||
},
|
||||
|
||||
_onWindowUnselected: function (actor, child) {
|
||||
this._setHighlightWindow(null);
|
||||
},
|
||||
|
||||
_onWindowSelected: function (actor, child) {
|
||||
this._setHighlightWindow(child._window);
|
||||
},
|
||||
|
||||
_onWindowActivate: function (actor, child) {
|
||||
let metaWindow = child._window;
|
||||
this.didActivateWindow = true;
|
||||
Main.overview.activateWindow(metaWindow, Clutter.get_current_event_time());
|
||||
this.emit('popup', false);
|
||||
this.actor.hide();
|
||||
},
|
||||
|
||||
_onWindowSelectionCancelled: function () {
|
||||
this.emit('highlight-window', null);
|
||||
this.emit('popup', false);
|
||||
this.actor.hide();
|
||||
}
|
||||
}
|
||||
|
||||
Signals.addSignalMethods(WellMenu.prototype);
|
||||
|
||||
function BaseWellItem(appInfo, isFavorite) {
|
||||
this._init(appInfo, isFavorite);
|
||||
}
|
||||
|
||||
BaseWellItem.prototype = {
|
||||
__proto__: AppIcon.AppIcon.prototype,
|
||||
|
||||
_init: function(appInfo, isFavorite, hasMenu) {
|
||||
AppIcon.AppIcon.prototype._init.call(this, appInfo, hasMenu ? AppIcon.MenuType.ON_RIGHT : AppIcon.MenuType.NONE);
|
||||
|
||||
_init: function(appInfo, isFavorite) {
|
||||
this.appInfo = appInfo;
|
||||
this.isFavorite = isFavorite;
|
||||
|
||||
this._draggable = DND.makeDraggable(this.actor, true);
|
||||
this.icon = new AppIcon.AppIcon(appInfo);
|
||||
this.windows = this.icon.windows;
|
||||
this.actor = new Shell.ButtonBox({ orientation: Big.BoxOrientation.VERTICAL,
|
||||
border: WELL_MENU_BORDER_WIDTH,
|
||||
corner_radius: WELL_MENU_CORNER_RADIUS,
|
||||
reactive: true });
|
||||
this.icon.actor._delegate = this;
|
||||
this._draggable = DND.makeDraggable(this.icon.actor, true);
|
||||
|
||||
// Do these as anonymous functions to avoid conflict with handlers in subclasses
|
||||
this.actor.connect('button-press-event', Lang.bind(this, function(actor, event) {
|
||||
@ -480,14 +751,15 @@ BaseWellItem.prototype = {
|
||||
if (!hover) {
|
||||
if (this.actor.pressed && this._dragStartX != null) {
|
||||
this.actor.fake_release();
|
||||
this._draggable.startDrag(this._dragStartX, this._dragStartY,
|
||||
Main.currentTime());
|
||||
this._draggable.startDrag(this.icon.actor, this._dragStartX, this._dragStartY,
|
||||
Clutter.get_current_event_time());
|
||||
} else {
|
||||
this._dragStartX = null;
|
||||
this._dragStartY = null;
|
||||
}
|
||||
}
|
||||
}));
|
||||
this.actor.append(this.icon.actor, Big.BoxPackFlags.NONE);
|
||||
},
|
||||
|
||||
shellWorkspaceLaunch : function() {
|
||||
@ -502,14 +774,14 @@ BaseWellItem.prototype = {
|
||||
this.appInfo.launch();
|
||||
},
|
||||
|
||||
getDragActor: function() {
|
||||
return this.createDragActor();
|
||||
getDragActor: function(stageX, stageY) {
|
||||
return this.icon.getDragActor(stageX, stageY);
|
||||
},
|
||||
|
||||
// Returns the original icon that is being used as a source for the cloned texture
|
||||
// that represents the item as it is being dragged.
|
||||
getDragActorSource: function() {
|
||||
return this.actor;
|
||||
return this.icon.getDragActorSource();
|
||||
}
|
||||
}
|
||||
|
||||
@ -521,17 +793,26 @@ RunningWellItem.prototype = {
|
||||
__proto__: BaseWellItem.prototype,
|
||||
|
||||
_init: function(appInfo, isFavorite) {
|
||||
BaseWellItem.prototype._init.call(this, appInfo, isFavorite, true);
|
||||
BaseWellItem.prototype._init.call(this, appInfo, isFavorite);
|
||||
|
||||
this._menuTimeoutId = 0;
|
||||
this._menu = null;
|
||||
this._dragStartX = 0;
|
||||
this._dragStartY = 0;
|
||||
|
||||
this.actor.connect('button-press-event', Lang.bind(this, this._onButtonPress));
|
||||
this.actor.connect('notify::hover', Lang.bind(this, this._onHoverChanged));
|
||||
this.actor.connect('activate', Lang.bind(this, this._onActivate));
|
||||
},
|
||||
|
||||
_onActivate: function (actor, event) {
|
||||
let modifiers = event.get_state();
|
||||
|
||||
if (this._menuTimeoutId > 0) {
|
||||
Mainloop.source_remove(this._menuTimeoutId);
|
||||
this._menuTimeoutId = 0;
|
||||
}
|
||||
|
||||
if (modifiers & Clutter.ModifierType.CONTROL_MASK) {
|
||||
this.appInfo.launch();
|
||||
} else {
|
||||
@ -542,32 +823,56 @@ RunningWellItem.prototype = {
|
||||
activateMostRecentWindow: function () {
|
||||
// The _get_windows_for_app sorts them for us
|
||||
let mostRecentWindow = this.windows[0];
|
||||
Main.overview.activateWindow(mostRecentWindow, Main.currentTime());
|
||||
Main.overview.activateWindow(mostRecentWindow, Clutter.get_current_event_time());
|
||||
},
|
||||
|
||||
highlightWindow: function(metaWindow) {
|
||||
Main.overview.getWorkspacesForWindow(metaWindow).setHighlightWindow(metaWindow);
|
||||
_onHoverChanged: function() {
|
||||
let hover = this.actor.hover;
|
||||
if (!hover && this._menuTimeoutId > 0) {
|
||||
Mainloop.source_remove(this._menuTimeoutId);
|
||||
this._menuTimeoutId = 0;
|
||||
}
|
||||
},
|
||||
|
||||
activateWindow: function(metaWindow) {
|
||||
if (metaWindow) {
|
||||
this._didActivateWindow = true;
|
||||
Main.overview.activateWindow(metaWindow, Main.currentTime());
|
||||
} else
|
||||
Main.overview.hide();
|
||||
_onButtonPress: function(actor, event) {
|
||||
if (this._menuTimeoutId > 0)
|
||||
Mainloop.source_remove(this._menuTimeoutId);
|
||||
this._menuTimeoutId = Mainloop.timeout_add(WELL_MENU_POPUP_TIMEOUT_MS,
|
||||
Lang.bind(this, this._popupMenu));
|
||||
return false;
|
||||
},
|
||||
|
||||
menuPoppedUp: function() {
|
||||
Main.overview.getWorkspacesForWindow(null).setApplicationWindowSelection(this.appInfo.get_id());
|
||||
},
|
||||
_popupMenu: function() {
|
||||
this._menuTimeoutId = 0;
|
||||
|
||||
menuPoppedDown: function() {
|
||||
if (this._didActivateWindow)
|
||||
return;
|
||||
this.actor.fake_release();
|
||||
|
||||
Main.overview.getWorkspacesForWindow(null).setApplicationWindowSelection(null);
|
||||
if (this._menu == null) {
|
||||
this._menu = new WellMenu(this);
|
||||
this._menu.connect('highlight-window', Lang.bind(this, function (menu, metaWindow) {
|
||||
Main.overview.getWorkspacesForWindow(metaWindow).setHighlightWindow(metaWindow);
|
||||
}));
|
||||
this._menu.connect('popup', Lang.bind(this, function (menu, isPoppedUp) {
|
||||
let id;
|
||||
|
||||
// If we successfully picked a window, don't reset the workspace
|
||||
// state, since picking a window already did that.
|
||||
if (!isPoppedUp && menu.didActivateWindow)
|
||||
return;
|
||||
if (isPoppedUp)
|
||||
id = this.appInfo.get_id();
|
||||
else
|
||||
id = null;
|
||||
|
||||
Main.overview.getWorkspacesForWindow(null).setApplicationWindowSelection(id);
|
||||
}));
|
||||
}
|
||||
|
||||
this._menu.popup();
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function InactiveWellItem(appInfo, isFavorite) {
|
||||
this._init(appInfo, isFavorite);
|
||||
@ -580,11 +885,21 @@ InactiveWellItem.prototype = {
|
||||
BaseWellItem.prototype._init.call(this, appInfo, isFavorite);
|
||||
|
||||
this.actor.connect('notify::pressed', Lang.bind(this, this._onPressedChanged));
|
||||
this.actor.connect('notify::hover', Lang.bind(this, this._onHoverChanged));
|
||||
this.actor.connect('activate', Lang.bind(this, this._onActivate));
|
||||
},
|
||||
|
||||
_onPressedChanged: function() {
|
||||
this.setHighlight(this.actor.pressed);
|
||||
let pressed = this.actor.pressed;
|
||||
if (pressed) {
|
||||
this.actor.border_color = WELL_MENU_BORDER_COLOR;
|
||||
} else {
|
||||
this.actor.border_color = TRANSPARENT_COLOR;
|
||||
}
|
||||
},
|
||||
|
||||
_onHoverChanged: function() {
|
||||
let hover = this.actor.hover;
|
||||
},
|
||||
|
||||
_onActivate: function() {
|
||||
@ -623,8 +938,9 @@ WellGrid.prototype = {
|
||||
nColumns = children.length;
|
||||
else
|
||||
nColumns = WELL_DEFAULT_COLUMNS;
|
||||
alloc.min_size = itemMin;
|
||||
alloc.natural_size = itemNatural * nColumns;
|
||||
let spacing = Math.max(nColumns - 1, 0) * WELL_ITEM_HSPACING;
|
||||
alloc.min_size = itemMin * nColumns + spacing;
|
||||
alloc.natural_size = itemNatural * nColumns + spacing;
|
||||
},
|
||||
|
||||
_getPreferredHeight: function (grid, forWidth, alloc) {
|
||||
@ -672,7 +988,7 @@ WellGrid.prototype = {
|
||||
y += itemHeight + WELL_ITEM_VSPACING;
|
||||
x = box.x1;
|
||||
} else {
|
||||
x += itemWidth;
|
||||
x += itemWidth + WELL_ITEM_HSPACING;
|
||||
}
|
||||
|
||||
if (atSeparator) {
|
||||
@ -722,28 +1038,19 @@ WellGrid.prototype = {
|
||||
let children = this._getItemChildren();
|
||||
if (children.length == 0)
|
||||
return [0, WELL_DEFAULT_COLUMNS, 0, 0];
|
||||
let nColumns = 0;
|
||||
let usedWidth = 0;
|
||||
if (forWidth < 0) {
|
||||
let nColumns;
|
||||
if (children.length < WELL_DEFAULT_COLUMNS)
|
||||
nColumns = children.length;
|
||||
else
|
||||
nColumns = WELL_DEFAULT_COLUMNS;
|
||||
} else {
|
||||
while (nColumns < WELL_DEFAULT_COLUMNS &&
|
||||
nColumns < children.length &&
|
||||
usedWidth + itemMinWidth <= forWidth) {
|
||||
// By including WELL_ITEM_MIN_HSPACING in usedWidth, we are ensuring
|
||||
// that the number of columns we end up with will allow the spacing
|
||||
// between the columns to be at least that value.
|
||||
usedWidth += itemMinWidth + WELL_ITEM_MIN_HSPACING;
|
||||
nColumns++;
|
||||
}
|
||||
|
||||
if (forWidth >= 0 && forWidth < minWidth) {
|
||||
log("WellGrid: trying to allocate for width " + forWidth + " but min is " + minWidth);
|
||||
/* FIXME - we should fall back to fewer than WELL_DEFAULT_COLUMNS here */
|
||||
}
|
||||
|
||||
if (nColumns == 0) {
|
||||
log("WellGrid: couldn't fit a column in width " + forWidth);
|
||||
/* FIXME - fall back to smaller icon size */
|
||||
}
|
||||
|
||||
let minWidth = itemMinWidth * nColumns;
|
||||
let horizSpacingTotal = Math.max(nColumns - 1, 0) * WELL_ITEM_HSPACING;
|
||||
let minWidth = itemMinWidth * nColumns + horizSpacingTotal;
|
||||
|
||||
let lastColumnIndex = nColumns - 1;
|
||||
let separatorColumns = lastColumnIndex - ((lastColumnIndex + this._separatorIndex) % nColumns);
|
||||
@ -753,7 +1060,7 @@ WellGrid.prototype = {
|
||||
if (forWidth < 0) {
|
||||
itemWidth = itemNaturalWidth;
|
||||
} else {
|
||||
itemWidth = Math.floor(forWidth / nColumns);
|
||||
itemWidth = Math.max(forWidth - horizSpacingTotal, 0) / nColumns;
|
||||
}
|
||||
|
||||
let itemNaturalHeight = 0;
|
||||
@ -763,7 +1070,7 @@ WellGrid.prototype = {
|
||||
itemNaturalHeight = childNatural;
|
||||
}
|
||||
|
||||
return [rows, nColumns, itemWidth, itemNaturalHeight];
|
||||
return [rows, WELL_DEFAULT_COLUMNS, itemWidth, itemNaturalHeight];
|
||||
},
|
||||
|
||||
_getItemPreferredWidth: function () {
|
||||
|
499
js/ui/appIcon.js
499
js/ui/appIcon.js
@ -3,95 +3,48 @@
|
||||
const Big = imports.gi.Big;
|
||||
const Clutter = imports.gi.Clutter;
|
||||
const GLib = imports.gi.GLib;
|
||||
const Lang = imports.lang;
|
||||
const Mainloop = imports.mainloop;
|
||||
const Pango = imports.gi.Pango;
|
||||
const Shell = imports.gi.Shell;
|
||||
const Signals = imports.signals;
|
||||
const Gettext = imports.gettext.domain('gnome-shell');
|
||||
const _ = Gettext.gettext;
|
||||
const Lang = imports.lang;
|
||||
|
||||
const GenericDisplay = imports.ui.genericDisplay;
|
||||
const Main = imports.ui.main;
|
||||
const Workspaces = imports.ui.workspaces;
|
||||
|
||||
const GLOW_COLOR = new Clutter.Color();
|
||||
GLOW_COLOR.from_pixel(0x4f6ba4ff);
|
||||
const GLOW_PADDING_HORIZONTAL = 3;
|
||||
const GLOW_PADDING_VERTICAL = 3;
|
||||
|
||||
const APPICON_ICON_SIZE = 48;
|
||||
const APP_ICON_SIZE = 48;
|
||||
|
||||
const APPICON_PADDING = 1;
|
||||
const APPICON_BORDER_WIDTH = 1;
|
||||
const APPICON_CORNER_RADIUS = 4;
|
||||
|
||||
const APPICON_MENU_POPUP_TIMEOUT_MS = 600;
|
||||
|
||||
const APPICON_DEFAULT_BORDER_COLOR = new Clutter.Color();
|
||||
APPICON_DEFAULT_BORDER_COLOR.from_pixel(0x787878ff);
|
||||
const APPICON_MENU_BACKGROUND_COLOR = new Clutter.Color();
|
||||
APPICON_MENU_BACKGROUND_COLOR.from_pixel(0x292929ff);
|
||||
const APPICON_MENU_FONT = 'Sans 14px';
|
||||
const APPICON_MENU_COLOR = new Clutter.Color();
|
||||
APPICON_MENU_COLOR.from_pixel(0xffffffff);
|
||||
const APPICON_MENU_SELECTED_COLOR = new Clutter.Color();
|
||||
APPICON_MENU_SELECTED_COLOR.from_pixel(0x005b97ff);
|
||||
const APPICON_MENU_SEPARATOR_COLOR = new Clutter.Color();
|
||||
APPICON_MENU_SEPARATOR_COLOR.from_pixel(0x787878ff);
|
||||
const APPICON_MENU_BORDER_WIDTH = 1;
|
||||
const APPICON_MENU_ARROW_SIZE = 12;
|
||||
const APPICON_MENU_CORNER_RADIUS = 4;
|
||||
const APPICON_MENU_PADDING = 4;
|
||||
|
||||
const TRANSPARENT_COLOR = new Clutter.Color();
|
||||
TRANSPARENT_COLOR.from_pixel(0x00000000);
|
||||
|
||||
const MenuType = { NONE: 0, ON_RIGHT: 1, BELOW: 2 };
|
||||
|
||||
function AppIcon(appInfo, menuType) {
|
||||
this._init(appInfo, menuType || MenuType.NONE);
|
||||
function AppIcon(appInfo) {
|
||||
this._init(appInfo);
|
||||
}
|
||||
|
||||
AppIcon.prototype = {
|
||||
_init : function(appInfo, menuType) {
|
||||
_init : function(appInfo) {
|
||||
this.appInfo = appInfo;
|
||||
this._menuType = menuType;
|
||||
this.windows = Shell.AppMonitor.get_default().get_windows_for_app(appInfo.get_id());
|
||||
for (let i = 0; i < this.windows.length; i++) {
|
||||
this.windows[i].connect('notify::user-time', Lang.bind(this, this._resortWindows));
|
||||
}
|
||||
this._resortWindows();
|
||||
|
||||
this.actor = new Shell.ButtonBox({ orientation: Big.BoxOrientation.VERTICAL,
|
||||
border: APPICON_BORDER_WIDTH,
|
||||
corner_radius: APPICON_CORNER_RADIUS,
|
||||
padding: APPICON_PADDING,
|
||||
reactive: true });
|
||||
this.actor._delegate = this;
|
||||
this.highlight_border_color = APPICON_DEFAULT_BORDER_COLOR;
|
||||
|
||||
if (menuType != MenuType.NONE) {
|
||||
this.windows = Shell.AppMonitor.get_default().get_windows_for_app(appInfo.get_id());
|
||||
for (let i = 0; i < this.windows.length; i++) {
|
||||
this.windows[i].connect('notify::user-time', Lang.bind(this, this._resortWindows));
|
||||
}
|
||||
this._resortWindows();
|
||||
|
||||
this.actor.connect('button-press-event', Lang.bind(this, this._updateMenuOnButtonPress));
|
||||
this.actor.connect('notify::hover', Lang.bind(this, this._updateMenuOnHoverChanged));
|
||||
this.actor.connect('activate', Lang.bind(this, this._updateMenuOnActivate));
|
||||
|
||||
this._menuTimeoutId = 0;
|
||||
this._menu = null;
|
||||
} else
|
||||
this.windows = [];
|
||||
this.actor = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL,
|
||||
corner_radius: 2,
|
||||
padding: 1,
|
||||
reactive: true });
|
||||
|
||||
let iconBox = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL,
|
||||
x_align: Big.BoxAlignment.CENTER,
|
||||
y_align: Big.BoxAlignment.CENTER,
|
||||
width: APPICON_ICON_SIZE,
|
||||
height: APPICON_ICON_SIZE });
|
||||
this.icon = appInfo.create_icon_texture(APPICON_ICON_SIZE);
|
||||
y_align: Big.BoxAlignment.CENTER });
|
||||
this.icon = appInfo.create_icon_texture(APP_ICON_SIZE);
|
||||
iconBox.append(this.icon, Big.BoxPackFlags.NONE);
|
||||
|
||||
this.actor.append(iconBox, Big.BoxPackFlags.EXPAND);
|
||||
|
||||
this._windows = Shell.AppMonitor.get_default().get_windows_for_app(appInfo.get_id());
|
||||
|
||||
let nameBox = new Shell.GenericContainer();
|
||||
nameBox.connect('get-preferred-width', Lang.bind(this, this._nameBoxGetPreferredWidth));
|
||||
nameBox.connect('get-preferred-height', Lang.bind(this, this._nameBoxGetPreferredHeight));
|
||||
@ -106,9 +59,9 @@ AppIcon.prototype = {
|
||||
nameBox.add_actor(this._name);
|
||||
this._glowBox = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL });
|
||||
let glowPath = GLib.filename_to_uri(global.imagedir + 'app-well-glow.png', '');
|
||||
for (let i = 0; i < this.windows.length && i < 3; i++) {
|
||||
for (let i = 0; i < this._windows.length && i < 3; i++) {
|
||||
let glow = Shell.TextureCache.get_default().load_uri_sync(Shell.TextureCachePolicy.FOREVER,
|
||||
glowPath, -1, -1);
|
||||
glowPath, -1, -1);
|
||||
glow.keep_aspect_ratio = false;
|
||||
this._glowBox.append(glow, Big.BoxPackFlags.EXPAND);
|
||||
}
|
||||
@ -160,413 +113,21 @@ AppIcon.prototype = {
|
||||
|
||||
_resortWindows: function() {
|
||||
this.windows.sort(function (a, b) {
|
||||
let visA = a.showing_on_its_workspace();
|
||||
let visB = b.showing_on_its_workspace();
|
||||
|
||||
if (visA && !visB)
|
||||
let timeA = a.get_user_time();
|
||||
let timeB = b.get_user_time();
|
||||
if (timeA == timeB)
|
||||
return 0;
|
||||
else if (timeA > timeB)
|
||||
return -1;
|
||||
else if (visB && !visA)
|
||||
return 1;
|
||||
else
|
||||
return b.get_user_time() - a.get_user_time();
|
||||
return 1;
|
||||
});
|
||||
},
|
||||
|
||||
// AppIcon itself is not a draggable, but if you want to make
|
||||
// a subclass of it draggable, you can use this method to create
|
||||
// a drag actor
|
||||
createDragActor: function() {
|
||||
return this.appInfo.create_icon_texture(APPICON_ICON_SIZE);
|
||||
getDragActor: function() {
|
||||
return this.appInfo.create_icon_texture(APP_ICON_SIZE);
|
||||
},
|
||||
|
||||
setHighlight: function(highlight) {
|
||||
if (highlight) {
|
||||
this.actor.border_color = this.highlight_border_color;
|
||||
} else {
|
||||
this.actor.border_color = TRANSPARENT_COLOR;
|
||||
}
|
||||
},
|
||||
|
||||
_updateMenuOnActivate: function(actor, event) {
|
||||
if (this._menuTimeoutId != 0) {
|
||||
Mainloop.source_remove(this._menuTimeoutId);
|
||||
this._menuTimeoutId = 0;
|
||||
}
|
||||
this.emit('activate');
|
||||
return false;
|
||||
},
|
||||
|
||||
_updateMenuOnHoverChanged: function() {
|
||||
if (!this.actor.hover && this._menuTimeoutId != 0) {
|
||||
Mainloop.source_remove(this._menuTimeoutId);
|
||||
this._menuTimeoutId = 0;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
_updateMenuOnButtonPress: function(actor, event) {
|
||||
if (this._menuTimeoutId != 0)
|
||||
Mainloop.source_remove(this._menuTimeoutId);
|
||||
this._menuTimeoutId = Mainloop.timeout_add(APPICON_MENU_POPUP_TIMEOUT_MS,
|
||||
Lang.bind(this, this.popupMenu));
|
||||
return false;
|
||||
},
|
||||
|
||||
popupMenu: function() {
|
||||
if (this._menuTimeoutId != 0) {
|
||||
Mainloop.source_remove(this._menuTimeoutId);
|
||||
this._menuTimeoutId = 0;
|
||||
}
|
||||
|
||||
this.actor.fake_release();
|
||||
|
||||
if (!this._menu) {
|
||||
this._menu = new AppIconMenu(this, this._menuType);
|
||||
this._menu.connect('highlight-window', Lang.bind(this, function (menu, window) {
|
||||
this.highlightWindow(window);
|
||||
}));
|
||||
this._menu.connect('activate-window', Lang.bind(this, function (menu, window) {
|
||||
this.activateWindow(window);
|
||||
}));
|
||||
this._menu.connect('popup', Lang.bind(this, function (menu, isPoppedUp) {
|
||||
if (isPoppedUp)
|
||||
this.menuPoppedUp();
|
||||
else
|
||||
this.menuPoppedDown();
|
||||
}));
|
||||
}
|
||||
|
||||
this._menu.popup();
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
// Default implementations; AppDisplay.RunningWellItem overrides these
|
||||
highlightWindow: function(window) {
|
||||
this.emit('highlight-window', window);
|
||||
},
|
||||
|
||||
activateWindow: function(window) {
|
||||
this.emit('activate-window', window);
|
||||
},
|
||||
|
||||
menuPoppedUp: function() {
|
||||
this.emit('menu-popped-up', this._menu);
|
||||
},
|
||||
|
||||
menuPoppedDown: function() {
|
||||
this.emit('menu-popped-down', this._menu);
|
||||
getDragActorSource: function() {
|
||||
return this.icon;
|
||||
}
|
||||
};
|
||||
|
||||
Signals.addSignalMethods(AppIcon.prototype);
|
||||
|
||||
function AppIconMenu(source, type) {
|
||||
this._init(source, type);
|
||||
}
|
||||
|
||||
AppIconMenu.prototype = {
|
||||
_init: function(source, type) {
|
||||
this._source = source;
|
||||
this._type = type;
|
||||
|
||||
this.actor = new Shell.GenericContainer({ reactive: true });
|
||||
this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
|
||||
this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
|
||||
this.actor.connect('allocate', Lang.bind(this, this._allocate));
|
||||
|
||||
this._windowContainer = new Shell.Menu({ orientation: Big.BoxOrientation.VERTICAL,
|
||||
border_color: source.highlight_border_color,
|
||||
border: APPICON_MENU_BORDER_WIDTH,
|
||||
background_color: APPICON_MENU_BACKGROUND_COLOR,
|
||||
padding: 4,
|
||||
corner_radius: APPICON_MENU_CORNER_RADIUS,
|
||||
width: Main.overview._dash.actor.width * 0.75 });
|
||||
this._windowContainer.connect('unselected', Lang.bind(this, this._onItemUnselected));
|
||||
this._windowContainer.connect('selected', Lang.bind(this, this._onItemSelected));
|
||||
this._windowContainer.connect('cancelled', Lang.bind(this, this._onWindowSelectionCancelled));
|
||||
this._windowContainer.connect('activate', Lang.bind(this, this._onItemActivate));
|
||||
this.actor.add_actor(this._windowContainer);
|
||||
|
||||
// Stay popped up on release over application icon
|
||||
this._windowContainer.set_persistent_source(this._source.actor);
|
||||
|
||||
// Intercept events while the menu has the pointer grab to do window-related effects
|
||||
this._windowContainer.connect('enter-event', Lang.bind(this, this._onMenuEnter));
|
||||
this._windowContainer.connect('leave-event', Lang.bind(this, this._onMenuLeave));
|
||||
this._windowContainer.connect('button-release-event', Lang.bind(this, this._onMenuButtonRelease));
|
||||
|
||||
this._arrow = new Shell.DrawingArea();
|
||||
this._arrow.connect('redraw', Lang.bind(this, function (area, texture) {
|
||||
Shell.draw_box_pointer(texture,
|
||||
this._type == MenuType.ON_RIGHT ? Clutter.Gravity.WEST : Clutter.Gravity.NORTH,
|
||||
source.highlight_border_color,
|
||||
APPICON_MENU_BACKGROUND_COLOR);
|
||||
}));
|
||||
this.actor.add_actor(this._arrow);
|
||||
|
||||
// Chain our visibility and lifecycle to that of the source
|
||||
source.actor.connect('notify::mapped', Lang.bind(this, function () {
|
||||
if (!source.actor.mapped)
|
||||
this._windowContainer.popdown();
|
||||
}));
|
||||
source.actor.connect('destroy', Lang.bind(this, function () { this.actor.destroy(); }));
|
||||
|
||||
global.stage.add_actor(this.actor);
|
||||
},
|
||||
|
||||
_getPreferredWidth: function(actor, forHeight, alloc) {
|
||||
let [min, natural] = this._windowContainer.get_preferred_width(forHeight);
|
||||
if (this._type == MenuType.ON_RIGHT) {
|
||||
min += APPICON_MENU_ARROW_SIZE;
|
||||
natural += APPICON_MENU_ARROW_SIZE;
|
||||
}
|
||||
alloc.min_size = min;
|
||||
alloc.natural_size = natural;
|
||||
},
|
||||
|
||||
_getPreferredHeight: function(actor, forWidth, alloc) {
|
||||
let [min, natural] = this._windowContainer.get_preferred_height(forWidth);
|
||||
if (this._type == MenuType.BELOW) {
|
||||
min += APPICON_MENU_ARROW_SIZE;
|
||||
natural += APPICON_MENU_ARROW_SIZE;
|
||||
}
|
||||
alloc.min_size = min;
|
||||
alloc.natural_size = natural;
|
||||
},
|
||||
|
||||
_allocate: function(actor, box, flags) {
|
||||
let childBox = new Clutter.ActorBox();
|
||||
|
||||
let width = box.x2 - box.x1;
|
||||
let height = box.y2 - box.y1;
|
||||
|
||||
if (this._type == MenuType.ON_RIGHT) {
|
||||
childBox.x1 = 0;
|
||||
childBox.x2 = APPICON_MENU_ARROW_SIZE;
|
||||
childBox.y1 = Math.floor((height / 2) - (APPICON_MENU_ARROW_SIZE / 2));
|
||||
childBox.y2 = childBox.y1 + APPICON_MENU_ARROW_SIZE;
|
||||
this._arrow.allocate(childBox, flags);
|
||||
|
||||
childBox.x1 = APPICON_MENU_ARROW_SIZE - APPICON_MENU_BORDER_WIDTH;
|
||||
childBox.x2 = width;
|
||||
childBox.y1 = 0;
|
||||
childBox.y2 = height;
|
||||
this._windowContainer.allocate(childBox, flags);
|
||||
} else /* MenuType.BELOW */ {
|
||||
childBox.x1 = Math.floor((width / 2) - (APPICON_MENU_ARROW_SIZE / 2));
|
||||
childBox.x2 = childBox.x1 + APPICON_MENU_ARROW_SIZE;
|
||||
childBox.y1 = 0;
|
||||
childBox.y2 = APPICON_MENU_ARROW_SIZE;
|
||||
this._arrow.allocate(childBox, flags);
|
||||
|
||||
childBox.x1 = 0;
|
||||
childBox.x2 = width;
|
||||
childBox.y1 = APPICON_MENU_ARROW_SIZE - APPICON_MENU_BORDER_WIDTH;
|
||||
childBox.y2 = height;
|
||||
this._windowContainer.allocate(childBox, flags);
|
||||
}
|
||||
},
|
||||
|
||||
_redisplay: function() {
|
||||
this._windowContainer.remove_all();
|
||||
|
||||
let windows = this._source.windows;
|
||||
|
||||
this._windowContainer.show();
|
||||
|
||||
let iconsDiffer = false;
|
||||
let texCache = Shell.TextureCache.get_default();
|
||||
let firstIcon = windows[0].mini_icon;
|
||||
for (let i = 1; i < windows.length; i++) {
|
||||
if (!texCache.pixbuf_equal(windows[i].mini_icon, firstIcon)) {
|
||||
iconsDiffer = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let activeWorkspace = global.screen.get_active_workspace();
|
||||
|
||||
let currentWorkspaceWindows = windows.filter(function (w) {
|
||||
return w.get_workspace() == activeWorkspace;
|
||||
});
|
||||
let otherWorkspaceWindows = windows.filter(function (w) {
|
||||
return w.get_workspace() != activeWorkspace;
|
||||
});
|
||||
|
||||
this._appendWindows(currentWorkspaceWindows, iconsDiffer);
|
||||
if (currentWorkspaceWindows.length > 0 && otherWorkspaceWindows.length > 0) {
|
||||
this._appendSeparator();
|
||||
}
|
||||
this._appendWindows(otherWorkspaceWindows, iconsDiffer);
|
||||
|
||||
this._appendSeparator();
|
||||
|
||||
this._newWindowMenuItem = this._appendMenuItem(null, _("New Window"));
|
||||
|
||||
this._highlightedItem = null;
|
||||
},
|
||||
|
||||
_appendSeparator: function () {
|
||||
let box = new Big.Box({ padding_top: 2, padding_bottom: 2 });
|
||||
box.append(new Clutter.Rectangle({ height: 1,
|
||||
color: APPICON_MENU_SEPARATOR_COLOR }),
|
||||
Big.BoxPackFlags.EXPAND);
|
||||
this._windowContainer.append_separator(box, Big.BoxPackFlags.NONE);
|
||||
},
|
||||
|
||||
_appendMenuItem: function(iconTexture, labelText) {
|
||||
/* Use padding here rather than spacing in the box above so that
|
||||
* we have a larger reactive area.
|
||||
*/
|
||||
let box = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL,
|
||||
padding_top: 4,
|
||||
padding_bottom: 4,
|
||||
spacing: 4,
|
||||
reactive: true });
|
||||
let vCenter;
|
||||
if (iconTexture != null) {
|
||||
vCenter = new Big.Box({ y_align: Big.BoxAlignment.CENTER });
|
||||
vCenter.append(iconTexture, Big.BoxPackFlags.NONE);
|
||||
box.append(vCenter, Big.BoxPackFlags.NONE);
|
||||
}
|
||||
vCenter = new Big.Box({ y_align: Big.BoxAlignment.CENTER });
|
||||
let label = new Clutter.Text({ text: labelText,
|
||||
font_name: APPICON_MENU_FONT,
|
||||
ellipsize: Pango.EllipsizeMode.END,
|
||||
color: APPICON_MENU_COLOR });
|
||||
vCenter.append(label, Big.BoxPackFlags.NONE);
|
||||
box.append(vCenter, Big.BoxPackFlags.NONE);
|
||||
this._windowContainer.append(box, Big.BoxPackFlags.NONE);
|
||||
return box;
|
||||
},
|
||||
|
||||
_appendWindows: function (windows, iconsDiffer) {
|
||||
for (let i = 0; i < windows.length; i++) {
|
||||
let metaWindow = windows[i];
|
||||
|
||||
let icon = null;
|
||||
if (iconsDiffer) {
|
||||
icon = Shell.TextureCache.get_default().bind_pixbuf_property(metaWindow, "mini-icon");
|
||||
}
|
||||
let box = this._appendMenuItem(icon, metaWindow.title);
|
||||
box._window = metaWindow;
|
||||
}
|
||||
},
|
||||
|
||||
popup: function() {
|
||||
let [stageX, stageY] = this._source.actor.get_transformed_position();
|
||||
let [stageWidth, stageHeight] = this._source.actor.get_transformed_size();
|
||||
|
||||
this._redisplay();
|
||||
|
||||
this._windowContainer.popup(0, Main.currentTime());
|
||||
|
||||
this.emit('popup', true);
|
||||
|
||||
let x, y;
|
||||
if (this._type == MenuType.ON_RIGHT) {
|
||||
x = Math.floor(stageX + stageWidth);
|
||||
y = Math.floor(stageY + (stageHeight / 2) - (this.actor.height / 2));
|
||||
} else {
|
||||
x = Math.floor(stageX + (stageWidth / 2) - (this.actor.width / 2));
|
||||
y = Math.floor(stageY + stageHeight);
|
||||
}
|
||||
|
||||
this.actor.set_position(x, y);
|
||||
this.actor.show();
|
||||
},
|
||||
|
||||
popdown: function() {
|
||||
this._windowContainer.popdown();
|
||||
this.emit('popup', false);
|
||||
this.actor.hide();
|
||||
},
|
||||
|
||||
selectWindow: function(metaWindow) {
|
||||
this._selectMenuItemForWindow(metaWindow);
|
||||
},
|
||||
|
||||
_findMetaWindowForActor: function (actor) {
|
||||
if (actor._delegate instanceof Workspaces.WindowClone)
|
||||
return actor._delegate.metaWindow;
|
||||
else if (actor.get_meta_window)
|
||||
return actor.get_meta_window();
|
||||
return null;
|
||||
},
|
||||
|
||||
// This function is called while the menu has a pointer grab; what we want
|
||||
// to do is see if the mouse was released over a window representation
|
||||
_onMenuButtonRelease: function (actor, event) {
|
||||
let metaWindow = this._findMetaWindowForActor(event.get_source());
|
||||
if (metaWindow) {
|
||||
this.emit('activate-window', metaWindow);
|
||||
}
|
||||
},
|
||||
|
||||
_updateHighlight: function (item) {
|
||||
if (this._highlightedItem) {
|
||||
this._highlightedItem.background_color = TRANSPARENT_COLOR;
|
||||
this.emit('highlight-window', null);
|
||||
}
|
||||
this._highlightedItem = item;
|
||||
if (this._highlightedItem) {
|
||||
this._highlightedItem.background_color = APPICON_MENU_SELECTED_COLOR;
|
||||
let window = this._highlightedItem._window;
|
||||
if (window)
|
||||
this.emit('highlight-window', window);
|
||||
}
|
||||
},
|
||||
|
||||
_selectMenuItemForWindow: function (metaWindow) {
|
||||
let children = this._windowContainer.get_children();
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
let child = children[i];
|
||||
let menuMetaWindow = child._window;
|
||||
if (menuMetaWindow == metaWindow)
|
||||
this._updateHighlight(child);
|
||||
}
|
||||
},
|
||||
|
||||
// Called while menu has a pointer grab
|
||||
_onMenuEnter: function (actor, event) {
|
||||
let metaWindow = this._findMetaWindowForActor(event.get_source());
|
||||
if (metaWindow) {
|
||||
this._selectMenuItemForWindow(metaWindow);
|
||||
}
|
||||
},
|
||||
|
||||
// Called while menu has a pointer grab
|
||||
_onMenuLeave: function (actor, event) {
|
||||
let metaWindow = this._findMetaWindowForActor(event.get_source());
|
||||
if (metaWindow) {
|
||||
this._updateHighlight(null);
|
||||
}
|
||||
},
|
||||
|
||||
_onItemUnselected: function (actor, child) {
|
||||
this._updateHighlight(null);
|
||||
},
|
||||
|
||||
_onItemSelected: function (actor, child) {
|
||||
this._updateHighlight(child);
|
||||
},
|
||||
|
||||
_onItemActivate: function (actor, child) {
|
||||
if (child._window) {
|
||||
let metaWindow = child._window;
|
||||
this.emit('activate-window', metaWindow);
|
||||
} else if (child == this._newWindowMenuItem) {
|
||||
this._source.appInfo.launch();
|
||||
this.emit('activate-window', null);
|
||||
}
|
||||
this.popdown();
|
||||
},
|
||||
|
||||
_onWindowSelectionCancelled: function () {
|
||||
this.emit('highlight-window', null);
|
||||
this.popdown();
|
||||
}
|
||||
};
|
||||
|
||||
Signals.addSignalMethods(AppIconMenu.prototype);
|
||||
|
@ -91,11 +91,11 @@ const ANIMATION_TIME = 0.25;
|
||||
* size -- size in pixels of both the button and the icon it contains
|
||||
* texture -- optional, must be used if the texture for the icon is already created (else, use setIconFromName)
|
||||
*/
|
||||
function IconButton(parent, size, texture) {
|
||||
function iconButton(parent, size, texture) {
|
||||
this._init(parent, size, texture);
|
||||
}
|
||||
|
||||
IconButton.prototype = {
|
||||
iconButton.prototype = {
|
||||
_init : function(parent, size, texture) {
|
||||
this._size = size;
|
||||
if (texture)
|
||||
@ -170,3 +170,4 @@ IconButton.prototype = {
|
||||
transition :"easeOutQuad" });
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -397,7 +397,7 @@ MoreLink.prototype = {
|
||||
|
||||
let text = new Clutter.Text({ font_name: "Sans 12px",
|
||||
color: BRIGHT_TEXT_COLOR,
|
||||
text: _("More") });
|
||||
text: _("Browse") });
|
||||
this.actor.append(text, Big.BoxPackFlags.NONE);
|
||||
|
||||
this.actor.connect('button-press-event', Lang.bind(this, function (b, e) {
|
||||
@ -506,13 +506,6 @@ SectionHeader.prototype = {
|
||||
this.backLink.actor.hide();
|
||||
},
|
||||
|
||||
setMoreLinkVisible : function(visible) {
|
||||
if (visible)
|
||||
this.moreLink.actor.show();
|
||||
else
|
||||
this.moreLink.actor.hide();
|
||||
},
|
||||
|
||||
setCountText : function(countText) {
|
||||
if (countText == "") {
|
||||
this.countText.hide();
|
||||
@ -620,7 +613,6 @@ Dash.prototype = {
|
||||
/***** Search *****/
|
||||
|
||||
this._searchActive = false;
|
||||
this._searchPending = false;
|
||||
this._searchEntry = new SearchEntry();
|
||||
this.searchArea.append(this._searchEntry.actor, Big.BoxPackFlags.EXPAND);
|
||||
|
||||
@ -628,9 +620,7 @@ Dash.prototype = {
|
||||
this._searchEntry.entry.connect('text-changed', Lang.bind(this, function (se, prop) {
|
||||
let text = this._searchEntry.getText();
|
||||
text = text.replace(/^\s+/g, "").replace(/\s+$/g, "")
|
||||
let searchPreviouslyActive = this._searchActive;
|
||||
this._searchActive = text != '';
|
||||
this._searchPending = this._searchActive && !searchPreviouslyActive;
|
||||
this._updateDashActors();
|
||||
if (!this._searchActive) {
|
||||
if (this._searchTimeoutId > 0) {
|
||||
@ -789,8 +779,8 @@ Dash.prototype = {
|
||||
|
||||
this._docsSection = new Section(_("RECENT DOCUMENTS"));
|
||||
|
||||
this._docDisplay = new DocDisplay.DashDocDisplay();
|
||||
this._docsSection.content.append(this._docDisplay.actor, Big.BoxPackFlags.EXPAND);
|
||||
let docDisplay = new DocDisplay.DashDocDisplay();
|
||||
this._docsSection.content.append(docDisplay.actor, Big.BoxPackFlags.EXPAND);
|
||||
|
||||
this._moreDocsPane = null;
|
||||
this._docsSection.header.moreLink.connect('activated', Lang.bind(this, function (link) {
|
||||
@ -802,12 +792,6 @@ Dash.prototype = {
|
||||
}
|
||||
}));
|
||||
|
||||
this._docDisplay.connect('changed', Lang.bind(this, function () {
|
||||
this._docsSection.header.setMoreLinkVisible(
|
||||
this._docDisplay.actor.get_children().length > 0);
|
||||
}));
|
||||
this._docDisplay.emit('changed');
|
||||
|
||||
this.sectionArea.append(this._docsSection.actor, Big.BoxPackFlags.EXPAND);
|
||||
|
||||
/***** Search Results *****/
|
||||
@ -887,28 +871,17 @@ Dash.prototype = {
|
||||
},
|
||||
|
||||
_updateDashActors: function() {
|
||||
if (this._searchPending) {
|
||||
this._searchResultsSection.actor.show();
|
||||
for (let i = 0; i < this._searchSections.length; i++) {
|
||||
let section = this._searchSections[i];
|
||||
section.header.actor.hide();
|
||||
section.resultArea.actor.hide();
|
||||
}
|
||||
this._appsSection.actor.hide();
|
||||
this._placesSection.actor.hide();
|
||||
this._docsSection.actor.hide();
|
||||
} else if (this._searchActive) {
|
||||
for (let i = 0; i < this._searchSections.length; i++) {
|
||||
let section = this._searchSections[i];
|
||||
section.header.actor.show();
|
||||
section.resultArea.actor.show();
|
||||
}
|
||||
} else {
|
||||
if (!this._searchActive && this._searchResultsSection.actor.visible) {
|
||||
this._showAllSearchSections();
|
||||
this._searchResultsSection.actor.hide();
|
||||
this._appsSection.actor.show();
|
||||
this._placesSection.actor.show();
|
||||
this._docsSection.actor.show();
|
||||
} else if (this._searchActive && !this._searchResultsSection.actor.visible) {
|
||||
this._searchResultsSection.actor.show();
|
||||
this._appsSection.actor.hide();
|
||||
this._placesSection.actor.hide();
|
||||
this._docsSection.actor.hide();
|
||||
}
|
||||
},
|
||||
|
||||
|
211
js/ui/dnd.js
211
js/ui/dnd.js
@ -8,25 +8,6 @@ const Tweener = imports.ui.tweener;
|
||||
|
||||
const SNAP_BACK_ANIMATION_TIME = 0.25;
|
||||
|
||||
let eventHandlerActor = null;
|
||||
let currentDraggable = null;
|
||||
|
||||
function _getEventHandlerActor() {
|
||||
if (!eventHandlerActor) {
|
||||
eventHandlerActor = new Clutter.Rectangle();
|
||||
eventHandlerActor.width = 0;
|
||||
eventHandlerActor.height = 0;
|
||||
global.stage.add_actor(eventHandlerActor);
|
||||
// We connect to 'event' rather than 'captured-event' because the capturing phase doesn't happen
|
||||
// when you've grabbed the pointer.
|
||||
eventHandlerActor.connect('event',
|
||||
function(actor, event) {
|
||||
return currentDraggable._onEvent(actor, event);
|
||||
});
|
||||
}
|
||||
return eventHandlerActor;
|
||||
}
|
||||
|
||||
function _Draggable(actor, manualMode) {
|
||||
this._init(actor, manualMode);
|
||||
}
|
||||
@ -37,11 +18,7 @@ _Draggable.prototype = {
|
||||
if (!manualMode)
|
||||
this.actor.connect('button-press-event',
|
||||
Lang.bind(this, this._onButtonPress));
|
||||
this._onEventId = null;
|
||||
|
||||
this._buttonDown = false; // The mouse button has been pressed and has not yet been released.
|
||||
this._dragInProgress = false; // The drag has been started, and has not been dropped or cancelled yet.
|
||||
this._snapBackInProgress = false; // The drag has been cancelled and the item is in the process of snapping back.
|
||||
this._haveSourceGrab = false;
|
||||
},
|
||||
|
||||
_onButtonPress : function (actor, event) {
|
||||
@ -50,8 +27,8 @@ _Draggable.prototype = {
|
||||
if (Tweener.getTweenCount(actor))
|
||||
return false;
|
||||
|
||||
this._buttonDown = true;
|
||||
this._grabActor();
|
||||
this._haveSourceGrab = true;
|
||||
this._grabActor(actor);
|
||||
|
||||
let [stageX, stageY] = event.get_coords();
|
||||
this._dragStartX = stageX;
|
||||
@ -60,69 +37,41 @@ _Draggable.prototype = {
|
||||
return false;
|
||||
},
|
||||
|
||||
_grabActor: function() {
|
||||
Clutter.grab_pointer(this.actor);
|
||||
this._onEventId = this.actor.connect('event',
|
||||
Lang.bind(this, this._onEvent));
|
||||
_grabActor : function (actor) {
|
||||
Clutter.grab_pointer(actor);
|
||||
|
||||
// We intercept motion and button-release events so that when
|
||||
// you release after dragging, the app doesn't see that and
|
||||
// think you just clicked. We connect to 'event' rather than
|
||||
// 'captured-event' because the capturing phase doesn't happen
|
||||
// when you've grabbed the pointer.
|
||||
this._onEventId = actor.connect('event',
|
||||
Lang.bind(this, this._onEvent));
|
||||
},
|
||||
|
||||
_ungrabActor: function() {
|
||||
_ungrabActor : function (actor) {
|
||||
Clutter.ungrab_pointer();
|
||||
this.actor.disconnect(this._onEventId);
|
||||
this._onEventId = null;
|
||||
actor.disconnect(this._onEventId);
|
||||
},
|
||||
|
||||
_grabEvents: function() {
|
||||
Clutter.grab_pointer(_getEventHandlerActor());
|
||||
Clutter.grab_keyboard(_getEventHandlerActor());
|
||||
},
|
||||
|
||||
_ungrabEvents: function() {
|
||||
Clutter.ungrab_pointer();
|
||||
Clutter.ungrab_keyboard();
|
||||
},
|
||||
|
||||
_onEvent: function(actor, event) {
|
||||
// We intercept BUTTON_RELEASE event to know that the button was released in case we
|
||||
// didn't start the drag, to drop the draggable in case the drag was in progress, and
|
||||
// to complete the drag and ensure that whatever happens to be under the pointer does
|
||||
// not get triggered if the drag was cancelled with Esc.
|
||||
if (event.type() == Clutter.EventType.BUTTON_RELEASE) {
|
||||
this._buttonDown = false;
|
||||
if (this._dragInProgress) {
|
||||
return this._dragActorDropped(event);
|
||||
} else if (this._dragActor != null && !this._snapBackInProgress) {
|
||||
// Drag must have been cancelled with Esc.
|
||||
this._dragComplete();
|
||||
return true;
|
||||
} else {
|
||||
// Drag has never started.
|
||||
this._ungrabActor();
|
||||
_onEvent : function (actor, event) {
|
||||
if (this._dragActor) {
|
||||
if (actor != this._dragActor )
|
||||
return false;
|
||||
}
|
||||
// We intercept MOTION event to figure out if the drag has started and to draw
|
||||
// this._dragActor under the pointer when dragging is in progress
|
||||
} else if (event.type() == Clutter.EventType.MOTION) {
|
||||
if (this._dragInProgress) {
|
||||
return this._updateDragPosition(event);
|
||||
} else if (this._dragActor == null) {
|
||||
return this._maybeStartDrag(event);
|
||||
}
|
||||
// We intercept KEY_PRESS event so that we can process Esc key press to cancel
|
||||
// dragging and ignore all other key presses.
|
||||
} else if (event.type() == Clutter.EventType.KEY_PRESS && this._dragInProgress) {
|
||||
let symbol = event.get_key_symbol();
|
||||
if (symbol == Clutter.Escape) {
|
||||
this._cancelDrag(event.get_time());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (actor != this.actor)
|
||||
return false;
|
||||
|
||||
return false;
|
||||
if (event.type() == Clutter.EventType.BUTTON_RELEASE)
|
||||
return this._onButtonRelease(actor, event);
|
||||
else if (event.type() == Clutter.EventType.MOTION)
|
||||
return this._onMotion(actor, event);
|
||||
else
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* startDrag:
|
||||
* @actor: Origin actor for drag and drop
|
||||
* @stageX: X coordinate of event
|
||||
* @stageY: Y coordinate of event
|
||||
* @time: Event timestamp
|
||||
@ -131,14 +80,8 @@ _Draggable.prototype = {
|
||||
* This function is useful to call if you've specified manualMode
|
||||
* for the draggable.
|
||||
*/
|
||||
startDrag: function (stageX, stageY, time) {
|
||||
currentDraggable = this;
|
||||
this._dragInProgress = true;
|
||||
|
||||
startDrag: function (actor, stageX, stageY, time) {
|
||||
this.emit('drag-begin', time);
|
||||
if (this._onEventId)
|
||||
this._ungrabActor();
|
||||
this._grabEvents();
|
||||
|
||||
this._dragStartX = stageX;
|
||||
this._dragStartY = stageY;
|
||||
@ -169,59 +112,59 @@ _Draggable.prototype = {
|
||||
this._dragActorSource = this.actor;
|
||||
}
|
||||
this._dragOrigParent = undefined;
|
||||
if (this._haveSourceGrab) {
|
||||
this._haveSourceGrab = false;
|
||||
this._ungrabActor(actor);
|
||||
}
|
||||
this._grabActor(this._dragActor);
|
||||
|
||||
this._dragOffsetX = this._dragActor.x - this._dragStartX;
|
||||
this._dragOffsetY = this._dragActor.y - this._dragStartY;
|
||||
} else {
|
||||
this._dragActor = this.actor;
|
||||
this._dragActor = actor;
|
||||
this._dragActorSource = undefined;
|
||||
this._dragOrigParent = this.actor.get_parent();
|
||||
this._dragOrigParent = actor.get_parent();
|
||||
this._dragOrigX = this._dragActor.x;
|
||||
this._dragOrigY = this._dragActor.y;
|
||||
this._dragOrigScale = this._dragActor.scale_x;
|
||||
|
||||
let [actorStageX, actorStageY] = this.actor.get_transformed_position();
|
||||
let [actorStageX, actorStageY] = actor.get_transformed_position();
|
||||
this._dragOffsetX = actorStageX - this._dragStartX;
|
||||
this._dragOffsetY = actorStageY - this._dragStartY;
|
||||
|
||||
// Set the actor's scale such that it will keep the same
|
||||
// transformed size when it's reparented to the stage
|
||||
let [scaledWidth, scaledHeight] = this.actor.get_transformed_size();
|
||||
this.actor.set_scale(scaledWidth / this.actor.width,
|
||||
scaledHeight / this.actor.height);
|
||||
let [scaledWidth, scaledHeight] = actor.get_transformed_size();
|
||||
actor.set_scale(scaledWidth / actor.width,
|
||||
scaledHeight / actor.height);
|
||||
}
|
||||
|
||||
this._dragActor.reparent(this.actor.get_stage());
|
||||
this._dragActor.reparent(actor.get_stage());
|
||||
this._dragActor.raise_top();
|
||||
},
|
||||
|
||||
_maybeStartDrag: function(event) {
|
||||
_onMotion : function (actor, event) {
|
||||
let [stageX, stageY] = event.get_coords();
|
||||
|
||||
// See if the user has moved the mouse enough to trigger a drag
|
||||
// If we haven't begun a drag, see if the user has moved the
|
||||
// mouse enough to trigger a drag
|
||||
let threshold = Gtk.Settings.get_default().gtk_dnd_drag_threshold;
|
||||
if ((Math.abs(stageX - this._dragStartX) > threshold ||
|
||||
if (!this._dragActor &&
|
||||
(Math.abs(stageX - this._dragStartX) > threshold ||
|
||||
Math.abs(stageY - this._dragStartY) > threshold)) {
|
||||
this.startDrag(stageX, stageY, event.get_time());
|
||||
this._updateDragPosition(event);
|
||||
this.startDrag(actor, stageX, stageY, event.get_time());
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
_updateDragPosition : function (event) {
|
||||
let [stageX, stageY] = event.get_coords();
|
||||
|
||||
// If we are dragging, update the position
|
||||
if (this._dragActor) {
|
||||
this._dragActor.set_position(stageX + this._dragOffsetX,
|
||||
stageY + this._dragOffsetY);
|
||||
// Because we want to find out what other actor is located at the current position of this._dragActor,
|
||||
// we have to temporarily hide this._dragActor.
|
||||
this._dragActor.hide();
|
||||
let target = this._dragActor.get_stage().get_actor_at_pos(Clutter.PickMode.ALL,
|
||||
stageX + this._dragOffsetX,
|
||||
stageY + this._dragOffsetY);
|
||||
this._dragActor.hide();
|
||||
let target = actor.get_stage().get_actor_at_pos(Clutter.PickMode.ALL,
|
||||
stageX + this._dragOffsetX,
|
||||
stageY + this._dragOffsetY);
|
||||
this._dragActor.show();
|
||||
while (target) {
|
||||
if (target._delegate && target._delegate.handleDragOver) {
|
||||
@ -229,7 +172,7 @@ _Draggable.prototype = {
|
||||
// We currently loop through all parents on drag-over even if one of the children has handled it.
|
||||
// We can check the return value of the function and break the loop if it's true if we don't want
|
||||
// to continue checking the parents.
|
||||
target._delegate.handleDragOver(this.actor._delegate, this._dragActor,
|
||||
target._delegate.handleDragOver(this.actor._delegate, actor,
|
||||
(stageX + this._dragOffsetX - targX) / target.scale_x,
|
||||
(stageY + this._dragOffsetY - targY) / target.scale_y,
|
||||
event.get_time());
|
||||
@ -241,42 +184,40 @@ _Draggable.prototype = {
|
||||
return true;
|
||||
},
|
||||
|
||||
_dragActorDropped: function(event) {
|
||||
// Find a drop target. Because we want to find out what other actor is located at
|
||||
// the current position of this._dragActor, we have to temporarily hide this._dragActor.
|
||||
this._dragActor.hide();
|
||||
_onButtonRelease : function (actor, event) {
|
||||
this._ungrabActor(actor);
|
||||
|
||||
let dragging = (actor == this._dragActor);
|
||||
this._dragActor = undefined;
|
||||
|
||||
if (!dragging)
|
||||
return false;
|
||||
|
||||
// Find a drop target
|
||||
actor.hide();
|
||||
let [dropX, dropY] = event.get_coords();
|
||||
let target = this._dragActor.get_stage().get_actor_at_pos(Clutter.PickMode.ALL,
|
||||
dropX, dropY);
|
||||
this._dragActor.show();
|
||||
let target = actor.get_stage().get_actor_at_pos(Clutter.PickMode.ALL,
|
||||
dropX, dropY);
|
||||
actor.show();
|
||||
while (target) {
|
||||
if (target._delegate && target._delegate.acceptDrop) {
|
||||
let [targX, targY] = target.get_transformed_position();
|
||||
if (target._delegate.acceptDrop(this.actor._delegate, this._dragActor,
|
||||
if (target._delegate.acceptDrop(this.actor._delegate, actor,
|
||||
(dropX - targX) / target.scale_x,
|
||||
(dropY - targY) / target.scale_y,
|
||||
event.get_time())) {
|
||||
// If it accepted the drop without taking the actor,
|
||||
// destroy it.
|
||||
if (this._dragActor.get_parent() == this._dragActor.get_stage())
|
||||
this._dragActor.destroy();
|
||||
if (actor.get_parent() == actor.get_stage())
|
||||
actor.destroy();
|
||||
|
||||
this._dragInProgress = false;
|
||||
this.emit('drag-end', event.get_time(), true);
|
||||
this._dragComplete();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
target = target.get_parent();
|
||||
}
|
||||
|
||||
this._cancelDrag(event.get_time());
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
_cancelDrag: function(eventTime) {
|
||||
this._dragInProgress = false;
|
||||
// Snap back to the actor source if the source is still around, snap back
|
||||
// to the original location if the actor itself was being dragged or the
|
||||
// source is no longer around.
|
||||
@ -286,17 +227,17 @@ _Draggable.prototype = {
|
||||
[snapBackX, snapBackY] = this._dragActorSource.get_transformed_position();
|
||||
}
|
||||
|
||||
this._snapBackInProgress = true;
|
||||
// No target, so snap back
|
||||
Tweener.addTween(this._dragActor,
|
||||
Tweener.addTween(actor,
|
||||
{ x: snapBackX,
|
||||
y: snapBackY,
|
||||
time: SNAP_BACK_ANIMATION_TIME,
|
||||
transition: "easeOutQuad",
|
||||
onComplete: this._onSnapBackComplete,
|
||||
onCompleteScope: this,
|
||||
onCompleteParams: [this._dragActor, eventTime]
|
||||
onCompleteParams: [actor, event.get_time()]
|
||||
});
|
||||
return true;
|
||||
},
|
||||
|
||||
_onSnapBackComplete : function (dragActor, eventTime) {
|
||||
@ -308,16 +249,6 @@ _Draggable.prototype = {
|
||||
dragActor.destroy();
|
||||
}
|
||||
this.emit('drag-end', eventTime, false);
|
||||
|
||||
this._snapBackInProgress = false;
|
||||
if (!this._buttonDown)
|
||||
this._dragComplete();
|
||||
},
|
||||
|
||||
_dragComplete: function() {
|
||||
this._dragActor = undefined;
|
||||
currentDraggable = null;
|
||||
this._ungrabEvents();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -150,10 +150,9 @@ DocDisplay.prototype = {
|
||||
// Gets the list of recent items from the recent items manager.
|
||||
_refreshCache : function() {
|
||||
if (!this._docsStale)
|
||||
return true;
|
||||
return;
|
||||
this._allItems = this._docManager.getItems();
|
||||
this._docsStale = false;
|
||||
return false;
|
||||
},
|
||||
|
||||
// Sets the list of the displayed items based on how recently they were last visited.
|
||||
@ -172,24 +171,21 @@ DocDisplay.prototype = {
|
||||
// them once when they are returned by this._recentManager.get_items() to avoid having to do
|
||||
// this sorting each time, but the sorting seems to be very fast anyway, so there is no need
|
||||
// to introduce an additional class variable.
|
||||
this._matchedItems = {};
|
||||
this._matchedItemKeys = [];
|
||||
this._matchedItems = [];
|
||||
let docIdsToRemove = [];
|
||||
for (docId in this._allItems) {
|
||||
// this._allItems[docId].exists() checks if the resource still exists
|
||||
if (this._allItems[docId].exists()) {
|
||||
this._matchedItems[docId] = 1;
|
||||
this._matchedItemKeys.push(docId);
|
||||
} else {
|
||||
if (this._allItems[docId].exists())
|
||||
this._matchedItems.push(docId);
|
||||
else
|
||||
docIdsToRemove.push(docId);
|
||||
}
|
||||
}
|
||||
|
||||
for (docId in docIdsToRemove) {
|
||||
delete this._allItems[docId];
|
||||
}
|
||||
|
||||
this._matchedItemKeys.sort(Lang.bind(this, this._compareItems));
|
||||
this._matchedItems.sort(Lang.bind(this, function (a,b) { return this._compareItems(a,b); }));
|
||||
},
|
||||
|
||||
// Compares items associated with the item ids based on how recently the items
|
||||
@ -302,7 +298,7 @@ DashDocDisplayItem.prototype = {
|
||||
shellWorkspaceLaunch: function () {
|
||||
this._info.launch();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Class used to display two column recent documents in the dash
|
||||
@ -436,9 +432,5 @@ DashDocDisplay.prototype = {
|
||||
let display = new DashDocDisplayItem(docInfo);
|
||||
this.actor.add_actor(display.actor);
|
||||
}
|
||||
this.emit('changed');
|
||||
}
|
||||
};
|
||||
|
||||
Signals.addSignalMethods(DashDocDisplay.prototype);
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
|
||||
|
||||
const St = imports.gi.St;
|
||||
const Nbtk = imports.gi.Nbtk;
|
||||
|
||||
const Tweener = imports.ui.tweener;
|
||||
|
||||
@ -25,8 +25,7 @@ function _patchContainerClass(containerClass) {
|
||||
};
|
||||
}
|
||||
|
||||
_patchContainerClass(St.BoxLayout);
|
||||
_patchContainerClass(St.Table);
|
||||
_patchContainerClass(Nbtk.BoxLayout);
|
||||
|
||||
function init() {
|
||||
Tweener.init();
|
||||
|
@ -17,11 +17,6 @@ const DND = imports.ui.dnd;
|
||||
const Link = imports.ui.link;
|
||||
const Main = imports.ui.main;
|
||||
|
||||
const RedisplayFlags = { NONE: 0,
|
||||
RESET_CONTROLS: 1 << 0,
|
||||
FULL: 1 << 1,
|
||||
SUBSEARCH: 1 << 2 };
|
||||
|
||||
const ITEM_DISPLAY_NAME_COLOR = new Clutter.Color();
|
||||
ITEM_DISPLAY_NAME_COLOR.from_pixel(0xffffffff);
|
||||
const ITEM_DISPLAY_DESCRIPTION_COLOR = new Clutter.Color();
|
||||
@ -98,7 +93,7 @@ GenericDisplayItem.prototype = {
|
||||
infoIconUri,
|
||||
INFORMATION_BUTTON_SIZE,
|
||||
INFORMATION_BUTTON_SIZE);
|
||||
this._informationButton = new Button.IconButton(this.actor, INFORMATION_BUTTON_SIZE, infoIcon);
|
||||
this._informationButton = new Button.iconButton(this.actor, INFORMATION_BUTTON_SIZE, infoIcon);
|
||||
let buttonBox = new Big.Box({ width: INFORMATION_BUTTON_SIZE + 2 * DEFAULT_PADDING,
|
||||
height: INFORMATION_BUTTON_SIZE,
|
||||
padding_left: DEFAULT_PADDING, padding_right: DEFAULT_PADDING,
|
||||
@ -126,8 +121,6 @@ GenericDisplayItem.prototype = {
|
||||
this._description = null;
|
||||
this._icon = null;
|
||||
|
||||
this._initialLoadComplete = false;
|
||||
|
||||
// An array of details description actors that we create over time for the item.
|
||||
// It is used for updating the description text inside the details actor when
|
||||
// the description text for the item is updated.
|
||||
@ -344,10 +337,9 @@ GenericDisplay.prototype = {
|
||||
|
||||
// map<itemId, Object> where Object represents the item info
|
||||
this._allItems = {};
|
||||
// set<itemId>
|
||||
this._matchedItems = {};
|
||||
// sorted array of items matched by search
|
||||
this._matchedItemKeys = [];
|
||||
// an array of itemIds of items that match the current request
|
||||
// in the order in which the items should be displayed
|
||||
this._matchedItems = [];
|
||||
// map<itemId, GenericDisplayItem>
|
||||
this._displayedItems = {};
|
||||
this._openDetailIndex = -1;
|
||||
@ -365,16 +357,8 @@ GenericDisplay.prototype = {
|
||||
|
||||
// Sets the search string and displays the matching items.
|
||||
setSearch: function(text) {
|
||||
let lowertext = text.toLowerCase();
|
||||
if (lowertext == this._search)
|
||||
return;
|
||||
let flags = RedisplayFlags.RESET_CONTROLS;
|
||||
if (this._search != '') {
|
||||
if (lowertext.indexOf(this._search) == 0)
|
||||
flags |= RedisplayFlags.SUBSEARCH;
|
||||
}
|
||||
this._search = lowertext;
|
||||
this._redisplay(flags);
|
||||
this._search = text.toLowerCase();
|
||||
this._redisplay(true);
|
||||
},
|
||||
|
||||
// Launches the item that is currently selected, closing the Overview
|
||||
@ -446,16 +430,16 @@ GenericDisplay.prototype = {
|
||||
// positive number when this._mathedItems.length is 0
|
||||
// This can be triggered if a search string is entered for which there are no matches.
|
||||
// log("this._mathedItems.length: " + this._matchedItems.length + " this._list.displayedCount " + this._list.displayedCount);
|
||||
return this._matchedItemKeys.length > 0;
|
||||
return this._matchedItems.length > 0;
|
||||
},
|
||||
|
||||
getMatchedItemsCount: function() {
|
||||
return this._matchedItemKeys.length;
|
||||
return this._matchedItems.length;
|
||||
},
|
||||
|
||||
// Load the initial state
|
||||
load: function() {
|
||||
this._redisplay(RedisplayFlags.FULL);
|
||||
this._redisplay(true);
|
||||
},
|
||||
|
||||
// Should be called when the display is closed
|
||||
@ -486,14 +470,51 @@ GenericDisplay.prototype = {
|
||||
|
||||
//// Protected methods ////
|
||||
|
||||
_redisplayFull: function() {
|
||||
/*
|
||||
* Displays items that match the current request and should show up on the current page.
|
||||
* Updates the display control to reflect the matched items set and the page selected.
|
||||
*
|
||||
* resetDisplayControl - indicates if the display control should be re-created because
|
||||
* the results or the space allocated for them changed. If it's false,
|
||||
* the existing display control is used and only the page links are
|
||||
* updated to reflect the current page selection.
|
||||
*/
|
||||
_displayMatchedItems: function(resetDisplayControl) {
|
||||
// When generating a new list to display, we first remove all the old
|
||||
// displayed items which will unset the selection. So we need
|
||||
// to keep a flag which indicates if this display had the selection.
|
||||
let hadSelected = this.hasSelected();
|
||||
|
||||
this._removeAllDisplayItems();
|
||||
for (let itemId in this._allItems) {
|
||||
this._addDisplayItem(itemId);
|
||||
for (let i = 0; i < this._matchedItems.length; i++) {
|
||||
this._addDisplayItem(this._matchedItems[i]);
|
||||
}
|
||||
|
||||
if (hadSelected) {
|
||||
this._selectedIndex = -1;
|
||||
this.selectFirstItem();
|
||||
}
|
||||
|
||||
// Check if the pointer is over one of the items and display the information button if it is.
|
||||
// We want to do this between finishing our changes to the display and the point where
|
||||
// the display is redrawn.
|
||||
Mainloop.idle_add(Lang.bind(this,
|
||||
function() {
|
||||
let [child, x, y, mask] = Gdk.Screen.get_default().get_root_window().get_pointer();
|
||||
let actor = global.stage.get_actor_at_pos(Clutter.PickMode.REACTIVE,
|
||||
x, y);
|
||||
if (actor != null) {
|
||||
let item = this._findDisplayedByActor(actor);
|
||||
if (item != null) {
|
||||
item.onDrawnUnderPointer();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}),
|
||||
Meta.PRIORITY_BEFORE_REDRAW);
|
||||
},
|
||||
|
||||
// Creates a display item based on the information associated with itemId
|
||||
// Creates a display item based on the information associated with itemId
|
||||
// and adds it to the displayed items.
|
||||
_addDisplayItem : function(itemId) {
|
||||
if (this._displayedItems.hasOwnProperty(itemId)) {
|
||||
@ -564,131 +585,33 @@ GenericDisplay.prototype = {
|
||||
this.unsetSelected();
|
||||
},
|
||||
|
||||
_compareSearchMatch: function(a, b) {
|
||||
let countA = this._matchedItems[a];
|
||||
let countB = this._matchedItems[b];
|
||||
if (countA > countB)
|
||||
return -1;
|
||||
else if (countA < countB)
|
||||
return 1;
|
||||
else
|
||||
return this._compareItems(a, b);
|
||||
},
|
||||
|
||||
_setMatches: function(matches) {
|
||||
this._matchedItems = matches;
|
||||
this._matchedItemKeys = [];
|
||||
for (let itemId in this._matchedItems) {
|
||||
this._matchedItemKeys.push(itemId);
|
||||
}
|
||||
this._matchedItemKeys.sort(Lang.bind(this, this._compareSearchMatch));
|
||||
},
|
||||
|
||||
/**
|
||||
* _redisplaySubSearch:
|
||||
* A somewhat more optimized function called when we know
|
||||
* that we're going to be displaying a subset of the items
|
||||
* we already had, in the same order. In that case, we can
|
||||
* just hide the actors that shouldn't be shown.
|
||||
*/
|
||||
_redisplaySubSearch: function() {
|
||||
let matches = this._getSearchMatchedItems(true);
|
||||
|
||||
// Just hide all from the old set,
|
||||
// we'll show the ones we want below
|
||||
for (let itemId in this._displayedItems) {
|
||||
let item = this._displayedItems[itemId];
|
||||
item.actor.hide();
|
||||
}
|
||||
|
||||
this._setMatches(matches);
|
||||
|
||||
for (let itemId in matches) {
|
||||
let item = this._displayedItems[itemId];
|
||||
item.actor.show();
|
||||
}
|
||||
this._list.queue_relayout();
|
||||
},
|
||||
|
||||
_redisplayReordering: function() {
|
||||
if (!this._filterActive()) {
|
||||
this._setDefaultList();
|
||||
} else {
|
||||
this._setMatches(this._getSearchMatchedItems(false));
|
||||
}
|
||||
this._list.remove_all();
|
||||
for (let i = 0; i < this._matchedItemKeys.length; i++) {
|
||||
let itemId = this._matchedItemKeys[i];
|
||||
let item = this._displayedItems[itemId];
|
||||
item.actor.show();
|
||||
this._list.add_actor(item.actor);
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
* Updates the displayed items, applying the search string if one exists.
|
||||
* @flags: Flags controlling redisplay behavior as follows:
|
||||
* RESET_CONTROLS - indicates if the page selection should be reset when displaying the matching results.
|
||||
* We reset the page selection when the change in results was initiated by the user by
|
||||
* entering a different search criteria or by viewing the results list in a different
|
||||
* size mode, but we keep the page selection the same if the results got updated on
|
||||
* their own while the user was browsing through the result pages.
|
||||
* SUBSEARCH - Indicates that the current _search is a superstring of the previous
|
||||
* one, which implies we only need to re-search through previous results.
|
||||
*
|
||||
* resetPage - indicates if the page selection should be reset when displaying the matching results.
|
||||
* We reset the page selection when the change in results was initiated by the user by
|
||||
* entering a different search criteria or by viewing the results list in a different
|
||||
* size mode, but we keep the page selection the same if the results got updated on
|
||||
* their own while the user was browsing through the result pages.
|
||||
*/
|
||||
_redisplay: function(flags) {
|
||||
let resetPage = (flags & RedisplayFlags.RESET_CONTROLS) > 0;
|
||||
let isSubSearch = (flags & RedisplayFlags.SUBSEARCH) > 0;
|
||||
let fullReload = (flags & RedisplayFlags.FULL) > 0;
|
||||
|
||||
let hadSelected = this.hasSelected();
|
||||
|
||||
if (!this._initialLoadComplete || !this._refreshCache())
|
||||
fullReload = true;
|
||||
if (fullReload) {
|
||||
this._initialLoadComplete = true;
|
||||
this._redisplayFull();
|
||||
} if (isSubSearch) {
|
||||
this._redisplaySubSearch();
|
||||
} else {
|
||||
this._redisplayReordering();
|
||||
}
|
||||
_redisplay: function(resetPage) {
|
||||
this._refreshCache();
|
||||
if (!this._filterActive())
|
||||
this._setDefaultList();
|
||||
else
|
||||
this._doSearchFilter();
|
||||
|
||||
if (resetPage)
|
||||
this._list.page = 0;
|
||||
|
||||
if (hadSelected) {
|
||||
this._selectedIndex = -1;
|
||||
this.selectFirstItem();
|
||||
}
|
||||
|
||||
Mainloop.idle_add(Lang.bind(this, this._checkInformationIcon),
|
||||
Meta.PRIORITY_BEFORE_REDRAW);
|
||||
this._displayMatchedItems(true);
|
||||
|
||||
this.emit('redisplayed');
|
||||
},
|
||||
|
||||
// Check if the pointer is over one of the items and display the information button if it is.
|
||||
// We want to do this between finishing our changes to the display and the point where
|
||||
// the display is redrawn.
|
||||
_checkInformationIcon: function() {
|
||||
let [child, x, y, mask] = Gdk.Screen.get_default().get_root_window().get_pointer();
|
||||
let actor = global.stage.get_actor_at_pos(Clutter.PickMode.REACTIVE,
|
||||
x, y);
|
||||
if (actor != null) {
|
||||
let item = this._findDisplayedByActor(actor);
|
||||
if (item != null) {
|
||||
item.onDrawnUnderPointer();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
//// Pure virtual protected methods ////
|
||||
|
||||
|
||||
// Performs the steps needed to have the latest information about the items.
|
||||
// Implementation should return %true if we are up to date, and %false
|
||||
// if a full reload occurred.
|
||||
_refreshCache: function() {
|
||||
throw new Error("Not implemented");
|
||||
},
|
||||
@ -720,46 +643,62 @@ GenericDisplay.prototype = {
|
||||
|
||||
//// Private methods ////
|
||||
|
||||
_getItemSearchScore: function(itemId, terms) {
|
||||
let item = this._allItems[itemId];
|
||||
let score = 0;
|
||||
for (let i = 0; i < terms.length; i++) {
|
||||
let term = terms[i];
|
||||
if (this._isInfoMatching(item, term)) {
|
||||
score++;
|
||||
}
|
||||
}
|
||||
return score;
|
||||
},
|
||||
|
||||
_getSearchMatchedItems: function(isSubSearch) {
|
||||
_getSearchMatchedItems: function() {
|
||||
let matchedItemsForSearch = {};
|
||||
// Break the search up into terms, and search for each
|
||||
// individual term. Keep track of the number of terms
|
||||
// each item matched.
|
||||
let terms = this._search.split(/\s+/);
|
||||
let matchScores = {};
|
||||
|
||||
if (isSubSearch) {
|
||||
for (let i = 0; i < this._matchedItemKeys.length; i++) {
|
||||
let itemId = this._matchedItemKeys[i];
|
||||
let score = this._getItemSearchScore(itemId, terms);
|
||||
if (score > 0)
|
||||
matchScores[itemId] = score;
|
||||
}
|
||||
} else {
|
||||
for (let itemId in this._displayedItems) {
|
||||
let score = this._getItemSearchScore(itemId, terms);
|
||||
if (score > 0)
|
||||
matchScores[itemId] = score;
|
||||
for (let i = 0; i < terms.length; i++) {
|
||||
let term = terms[i];
|
||||
for (itemId in this._allItems) {
|
||||
let item = this._allItems[itemId];
|
||||
if (this._isInfoMatching(item, term)) {
|
||||
let count = matchedItemsForSearch[itemId];
|
||||
if (!count)
|
||||
count = 0;
|
||||
count += 1;
|
||||
matchedItemsForSearch[itemId] = count;
|
||||
}
|
||||
}
|
||||
}
|
||||
return matchScores;
|
||||
return matchedItemsForSearch;
|
||||
},
|
||||
|
||||
// Applies the search string to the list of items to find matches,
|
||||
// and displays the matching items.
|
||||
_doSearchFilter: function() {
|
||||
let matchedItemsForSearch;
|
||||
|
||||
if (this._filterActive()) {
|
||||
matchedItemsForSearch = this._getSearchMatchedItems();
|
||||
} else {
|
||||
matchedItemsForSearch = {};
|
||||
for (let itemId in this._allItems) {
|
||||
matchedItemsForSearch[itemId] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
this._matchedItems = [];
|
||||
for (itemId in matchedItemsForSearch) {
|
||||
this._matchedItems.push(itemId);
|
||||
}
|
||||
this._matchedItems.sort(Lang.bind(this, function (a, b) {
|
||||
let countA = matchedItemsForSearch[a];
|
||||
let countB = matchedItemsForSearch[b];
|
||||
if (countA > countB)
|
||||
return -1;
|
||||
else if (countA < countB)
|
||||
return 1;
|
||||
else
|
||||
return this._compareItems(a, b);
|
||||
}));
|
||||
},
|
||||
|
||||
/*
|
||||
* Updates the display control to reflect the matched items set and the page selected.
|
||||
*
|
||||
* resetDisplayControl - indicates if the display control should be re-created because
|
||||
* resetDisplayControl - indicates if the display control should be re-created because
|
||||
* the results or the space allocated for them changed. If it's false,
|
||||
* the existing display control is used and only the page links are
|
||||
* updated to reflect the current page selection.
|
||||
|
@ -1,151 +0,0 @@
|
||||
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
|
||||
|
||||
const Clutter = imports.gi.Clutter;
|
||||
const Lang = imports.lang;
|
||||
|
||||
const Main = imports.ui.main;
|
||||
const Tweener = imports.ui.tweener;
|
||||
|
||||
const SHADE_COLOR = new Clutter.Color();
|
||||
SHADE_COLOR.from_pixel(0x00000044);
|
||||
|
||||
/**
|
||||
* Lightbox:
|
||||
* @container: parent Clutter.Container
|
||||
* @width: (optional) shade actor width
|
||||
* @height: (optional) shade actor height
|
||||
*
|
||||
* Lightbox creates a dark translucent "shade" actor to hide the
|
||||
* contents of @container, and allows you to specify particular actors
|
||||
* in @container to highlight by bringing them above the shade. It
|
||||
* tracks added and removed actors in @container while the lightboxing
|
||||
* is active, and ensures that all actors are returned to their
|
||||
* original stacking order when the lightboxing is removed. (However,
|
||||
* if actors are restacked by outside code while the lightboxing is
|
||||
* active, the lightbox may later revert them back to their original
|
||||
* order.)
|
||||
*
|
||||
* By default, the shade window will have the height and width of
|
||||
* @container and will track any changes in its size. You can override
|
||||
* this by passing an explicit width and height
|
||||
*/
|
||||
function Lightbox(container, width, height) {
|
||||
this._init(container, width, height);
|
||||
}
|
||||
|
||||
Lightbox.prototype = {
|
||||
_init : function(container, width, height) {
|
||||
this._container = container;
|
||||
this._children = container.get_children();
|
||||
this.actor = new Clutter.Rectangle({ color: SHADE_COLOR,
|
||||
x: 0,
|
||||
y: 0,
|
||||
border_width: 0,
|
||||
reactive: true });
|
||||
|
||||
container.add_actor(this.actor);
|
||||
this.actor.raise_top();
|
||||
|
||||
this._destroySignalId = this.actor.connect('destroy', Lang.bind(this, this.destroy));
|
||||
|
||||
if (width && height) {
|
||||
this.actor.width = width;
|
||||
this.actor.height = height;
|
||||
this._allocationChangedSignalId = 0;
|
||||
} else {
|
||||
this.actor.width = container.width;
|
||||
this.actor.height = container.height;
|
||||
this._allocationChangedSignalId = container.connect('allocation-changed', Lang.bind(this, this._allocationChanged));
|
||||
}
|
||||
|
||||
this._actorAddedSignalId = container.connect('actor-added', Lang.bind(this, this._actorAdded));
|
||||
this._actorRemovedSignalId = container.connect('actor-removed', Lang.bind(this, this._actorRemoved));
|
||||
|
||||
this._highlighted = null;
|
||||
},
|
||||
|
||||
_allocationChanged : function(container, box, flags) {
|
||||
this.actor.width = this._container.width;
|
||||
this.actor.height = this._container.height;
|
||||
},
|
||||
|
||||
_actorAdded : function(container, newChild) {
|
||||
let children = this._container.get_children();
|
||||
let myIndex = children.indexOf(this.actor);
|
||||
let newChildIndex = children.indexOf(newChild);
|
||||
|
||||
if (newChildIndex > myIndex) {
|
||||
// The child was added above the shade (presumably it was
|
||||
// made the new top-most child). Move it below the shade,
|
||||
// and add it to this._children as the new topmost actor.
|
||||
newChild.lower(this.actor);
|
||||
this._children.push(newChild);
|
||||
} else if (newChildIndex == 0) {
|
||||
// Bottom of stack
|
||||
this._children.unshift(newChild);
|
||||
} else {
|
||||
// Somewhere else; insert it into the correct spot
|
||||
let prevChild = this._children.indexOf(children[newChildIndex - 1]);
|
||||
if (prevChild != -1) // paranoia
|
||||
this._children.splice(prevChild + 1, 0, newChild);
|
||||
}
|
||||
},
|
||||
|
||||
_actorRemoved : function(container, child) {
|
||||
let index = this._children.indexOf(child);
|
||||
if (index != -1) // paranoia
|
||||
this._children.splice(index, 1);
|
||||
|
||||
if (child == this._highlighted)
|
||||
this._highlighted = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* highlight:
|
||||
* @window: actor to highlight
|
||||
*
|
||||
* Highlights the indicated actor and unhighlights any other
|
||||
* currently-highlighted actor. With no arguments or a false/null
|
||||
* argument, all actors will be unhighlighted.
|
||||
*/
|
||||
highlight : function(window) {
|
||||
if (this._highlighted == window)
|
||||
return;
|
||||
|
||||
// Walk this._children raising and lowering actors as needed.
|
||||
// Things get a little tricky if the to-be-raised and
|
||||
// to-be-lowered actors were originally adjacent, in which
|
||||
// case we may need to indicate some *other* actor as the new
|
||||
// sibling of the to-be-lowered one.
|
||||
|
||||
let below = this.actor;
|
||||
for (let i = this._children.length - 1; i >= 0; i--) {
|
||||
if (this._children[i] == window)
|
||||
this._children[i].raise_top();
|
||||
else if (this._children[i] == this._highlighted)
|
||||
this._children[i].lower(below);
|
||||
else
|
||||
below = this._children[i];
|
||||
}
|
||||
|
||||
this._highlighted = window;
|
||||
},
|
||||
|
||||
/**
|
||||
* destroy:
|
||||
*
|
||||
* Destroys the lightbox. This is called automatically if the
|
||||
* lightbox's container is destroyed.
|
||||
*/
|
||||
destroy : function() {
|
||||
if (this._allocationChangedSignalId != 0)
|
||||
this._container.disconnect(this._allocationChangedSignalId);
|
||||
this._container.disconnect(this._actorAddedSignalId);
|
||||
this._container.disconnect(this._actorRemovedSignalId);
|
||||
|
||||
this.actor.disconnect(this._destroySignalId);
|
||||
|
||||
this.highlight(null);
|
||||
this.actor.destroy();
|
||||
}
|
||||
};
|
@ -4,7 +4,7 @@ const Big = imports.gi.Big;
|
||||
const Clutter = imports.gi.Clutter;
|
||||
const Gio = imports.gi.Gio;
|
||||
const Pango = imports.gi.Pango;
|
||||
const St = imports.gi.St;
|
||||
const Nbtk = imports.gi.Nbtk;
|
||||
const Shell = imports.gi.Shell;
|
||||
const Signals = imports.signals;
|
||||
const Lang = imports.lang;
|
||||
@ -37,7 +37,7 @@ function Notebook() {
|
||||
|
||||
Notebook.prototype = {
|
||||
_init: function() {
|
||||
this.actor = new St.BoxLayout({ vertical: true });
|
||||
this.actor = new Nbtk.BoxLayout({ vertical: true });
|
||||
|
||||
this.tabControls = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL,
|
||||
spacing: 4, padding: 2 });
|
||||
@ -48,9 +48,9 @@ Notebook.prototype = {
|
||||
|
||||
appendPage: function(name, child) {
|
||||
let labelOuterBox = new Big.Box({ padding: 2 });
|
||||
let labelBox = new St.BoxLayout({ reactive: true });
|
||||
let labelBox = new Nbtk.BoxLayout({ reactive: true });
|
||||
labelOuterBox.append(labelBox, Big.BoxPackFlags.NONE);
|
||||
let label = new St.Label({ text: name });
|
||||
let label = new Nbtk.Label({ text: name });
|
||||
labelBox.connect('button-press-event', Lang.bind(this, function () {
|
||||
this.selectChild(child);
|
||||
return true;
|
||||
@ -58,7 +58,7 @@ Notebook.prototype = {
|
||||
labelBox.add(label, { expand: true });
|
||||
this.tabControls.append(labelOuterBox, Big.BoxPackFlags.NONE);
|
||||
|
||||
let scrollview = new St.ScrollView({ x_fill: true, y_fill: true });
|
||||
let scrollview = new Nbtk.ScrollView({ x_fill: true, y_fill: true });
|
||||
scrollview.get_hscroll_bar().hide();
|
||||
scrollview.add_actor(child);
|
||||
|
||||
@ -123,17 +123,17 @@ Result.prototype = {
|
||||
|
||||
this.actor = new Big.Box();
|
||||
|
||||
let cmdTxt = new St.Label({ text: command });
|
||||
let cmdTxt = new Nbtk.Label({ text: command });
|
||||
cmdTxt.ellipsize = Pango.EllipsizeMode.END;
|
||||
|
||||
this.actor.append(cmdTxt, Big.BoxPackFlags.NONE);
|
||||
let resultTxt = new St.Label({ text: "r(" + index + ") = " + o });
|
||||
let resultTxt = new Nbtk.Label({ text: "r(" + index + ") = " + o });
|
||||
resultTxt.ellipsize = Pango.EllipsizeMode.END;
|
||||
|
||||
this.actor.append(resultTxt, Big.BoxPackFlags.NONE);
|
||||
let line = new Clutter.Rectangle({ name: "Separator",
|
||||
height: 1 });
|
||||
let padBin = new St.Bin({ name: "Separator", x_fill: true, y_fill: true });
|
||||
let padBin = new Nbtk.Bin({ name: "Separator", x_fill: true, y_fill: true });
|
||||
padBin.add_actor(line);
|
||||
this.actor.append(padBin, Big.BoxPackFlags.NONE);
|
||||
}
|
||||
@ -150,7 +150,7 @@ ActorHierarchy.prototype = {
|
||||
|
||||
this._parentList = [];
|
||||
|
||||
this.actor = new St.BoxLayout({ name: "ActorHierarchy", vertical: true });
|
||||
this.actor = new Nbtk.BoxLayout({ name: "ActorHierarchy", vertical: true });
|
||||
},
|
||||
|
||||
setTarget: function(actor) {
|
||||
@ -170,8 +170,8 @@ ActorHierarchy.prototype = {
|
||||
while ((parent = parent.get_parent()) != null) {
|
||||
this._parentList.push(parent);
|
||||
|
||||
let link = new St.Label({ reactive: true,
|
||||
text: "" + parent });
|
||||
let link = new Nbtk.Label({ reactive: true,
|
||||
text: "" + parent });
|
||||
this.actor.add_actor(link);
|
||||
let parentTarget = parent;
|
||||
link.connect('button-press-event', Lang.bind(this, function () {
|
||||
@ -201,7 +201,7 @@ PropertyInspector.prototype = {
|
||||
|
||||
this._parentList = [];
|
||||
|
||||
this.actor = new St.BoxLayout({ name: "PropertyInspector", vertical: true });
|
||||
this.actor = new Nbtk.BoxLayout({ name: "PropertyInspector", vertical: true });
|
||||
},
|
||||
|
||||
setTarget: function(actor) {
|
||||
@ -217,8 +217,8 @@ PropertyInspector.prototype = {
|
||||
valueStr = '<error>';
|
||||
}
|
||||
let propText = propName + ": " + valueStr;
|
||||
let propDisplay = new St.Label({ reactive: true,
|
||||
text: propText });
|
||||
let propDisplay = new Nbtk.Label({ reactive: true,
|
||||
text: propText });
|
||||
this.actor.add_actor(propDisplay);
|
||||
}
|
||||
}
|
||||
@ -231,15 +231,15 @@ function Inspector() {
|
||||
Inspector.prototype = {
|
||||
_init: function() {
|
||||
let width = 150;
|
||||
let eventHandler = new St.BoxLayout({ name: "LookingGlassDialog",
|
||||
vertical: false,
|
||||
y: Math.floor(global.stage.height/2),
|
||||
reactive: true });
|
||||
let eventHandler = new Nbtk.BoxLayout({ name: "LookingGlassDialog",
|
||||
vertical: false,
|
||||
y: Math.floor(global.stage.height/2),
|
||||
reactive: true });
|
||||
eventHandler.connect('notify::allocation', Lang.bind(this, function () {
|
||||
eventHandler.x = Math.floor((global.stage.width)/2 - (eventHandler.width)/2);
|
||||
}));
|
||||
global.stage.add_actor(eventHandler);
|
||||
let displayText = new St.Label();
|
||||
let displayText = new Nbtk.Label();
|
||||
eventHandler.add(displayText, { expand: true });
|
||||
|
||||
let borderPaintTarget = null;
|
||||
@ -302,9 +302,9 @@ LookingGlass.prototype = {
|
||||
// Sort of magic, but...eh.
|
||||
this._maxItems = 150;
|
||||
|
||||
this.actor = new St.BoxLayout({ name: "LookingGlassDialog",
|
||||
vertical: true,
|
||||
visible: false });
|
||||
this.actor = new Nbtk.BoxLayout({ name: "LookingGlassDialog",
|
||||
vertical: true,
|
||||
visible: false });
|
||||
|
||||
let gconf = Shell.GConf.get_default();
|
||||
gconf.watch_directory("/desktop/gnome/interface");
|
||||
@ -314,7 +314,7 @@ LookingGlass.prototype = {
|
||||
|
||||
global.stage.add_actor(this.actor);
|
||||
|
||||
let toolbar = new St.BoxLayout({ name: "Toolbar" });
|
||||
let toolbar = new Nbtk.BoxLayout({ name: "Toolbar" });
|
||||
this.actor.add_actor(toolbar);
|
||||
let inspectIcon = Shell.TextureCache.get_default().load_gicon(new Gio.ThemedIcon({ name: 'gtk-color-picker' }),
|
||||
24);
|
||||
@ -338,11 +338,11 @@ LookingGlass.prototype = {
|
||||
let notebook = new Notebook();
|
||||
this.actor.add(notebook.actor, { expand: true });
|
||||
|
||||
let emptyBox = new St.Bin();
|
||||
let emptyBox = new Nbtk.Bin();
|
||||
toolbar.add(emptyBox, { expand: true });
|
||||
toolbar.add_actor(notebook.tabControls);
|
||||
|
||||
this._evalBox = new St.BoxLayout({ name: "EvalBox", vertical: true });
|
||||
this._evalBox = new Nbtk.BoxLayout({ name: "EvalBox", vertical: true });
|
||||
notebook.appendPage('Evaluator', this._evalBox);
|
||||
|
||||
this._resultsArea = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL,
|
||||
@ -352,10 +352,10 @@ LookingGlass.prototype = {
|
||||
let entryArea = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL });
|
||||
this._evalBox.add_actor(entryArea);
|
||||
|
||||
let label = new St.Label({ text: 'js>>> ' });
|
||||
let label = new Nbtk.Label({ text: 'js>>> ' });
|
||||
entryArea.append(label, Big.BoxPackFlags.NONE);
|
||||
|
||||
this._entry = new St.Entry();
|
||||
this._entry = new Nbtk.Entry();
|
||||
/* unmapping the edit box will un-focus it, undo that */
|
||||
notebook.connect('selection', Lang.bind(this, function (nb, child) {
|
||||
if (child == this._evalBox)
|
||||
@ -525,15 +525,13 @@ LookingGlass.prototype = {
|
||||
if (this._open)
|
||||
return;
|
||||
|
||||
if (!Main.pushModal(this.actor))
|
||||
return;
|
||||
|
||||
this.actor.show();
|
||||
this.actor.lower(Main.chrome.actor);
|
||||
this._open = true;
|
||||
|
||||
Tweener.removeTweens(this.actor);
|
||||
|
||||
Main.pushModal(this.actor);
|
||||
global.stage.set_key_focus(this._entry);
|
||||
|
||||
Tweener.addTween(this.actor, { time: 0.5,
|
||||
|
105
js/ui/main.js
105
js/ui/main.js
@ -1,16 +1,15 @@
|
||||
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
|
||||
|
||||
const Clutter = imports.gi.Clutter;
|
||||
const DBus = imports.dbus;
|
||||
const Gdk = imports.gi.Gdk;
|
||||
const Gio = imports.gi.Gio;
|
||||
const GLib = imports.gi.GLib;
|
||||
const Lang = imports.lang;
|
||||
const Mainloop = imports.mainloop;
|
||||
const Meta = imports.gi.Meta;
|
||||
const Nbtk = imports.gi.Nbtk;
|
||||
const Shell = imports.gi.Shell;
|
||||
const Signals = imports.signals;
|
||||
const St = imports.gi.St;
|
||||
|
||||
const Chrome = imports.ui.chrome;
|
||||
const Environment = imports.ui.environment;
|
||||
@ -18,7 +17,6 @@ const Overview = imports.ui.overview;
|
||||
const Panel = imports.ui.panel;
|
||||
const RunDialog = imports.ui.runDialog;
|
||||
const LookingGlass = imports.ui.lookingGlass;
|
||||
const ShellDBus = imports.ui.shellDBus;
|
||||
const Sidebar = imports.ui.sidebar;
|
||||
const WindowManager = imports.ui.windowManager;
|
||||
|
||||
@ -33,7 +31,6 @@ let runDialog = null;
|
||||
let lookingGlass = null;
|
||||
let wm = null;
|
||||
let recorder = null;
|
||||
let shellDBusService = null;
|
||||
let modalCount = 0;
|
||||
let modalActorFocusStack = [];
|
||||
|
||||
@ -46,12 +43,6 @@ function start() {
|
||||
Gio.DesktopAppInfo.set_desktop_env("GNOME");
|
||||
|
||||
global.grab_dbus_service();
|
||||
shellDBusService = new ShellDBus.GnomeShell();
|
||||
// Force a connection now; dbus.js will do this internally
|
||||
// if we use its name acquisition stuff but we aren't right
|
||||
// now; to do so we'd need to convert from its async calls
|
||||
// back into sync ones.
|
||||
DBus.session.flush();
|
||||
|
||||
Environment.init();
|
||||
|
||||
@ -76,24 +67,15 @@ function start() {
|
||||
for (let i = 0; i < children.length; i++)
|
||||
children[i].destroy();
|
||||
|
||||
let themeContext = St.ThemeContext.get_for_stage (global.stage);
|
||||
let themeContext = Shell.ThemeContext.get_for_stage (global.stage);
|
||||
let stylesheetPath = global.datadir + "/theme/gnome-shell.css";
|
||||
let theme = new St.Theme ({ application_stylesheet: stylesheetPath });
|
||||
let theme = new Shell.Theme ({ application_stylesheet: stylesheetPath });
|
||||
themeContext.set_theme (theme);
|
||||
|
||||
global.connect('panel-run-dialog', function(panel) {
|
||||
// Make sure not more than one run dialog is shown.
|
||||
getRunDialog().open();
|
||||
});
|
||||
let shellwm = global.window_manager;
|
||||
shellwm.takeover_keybinding("panel_main_menu");
|
||||
shellwm.connect("keybinding::panel_main_menu", function () {
|
||||
overview.toggle();
|
||||
});
|
||||
shellwm.takeover_keybinding("panel_run_dialog");
|
||||
shellwm.connect("keybinding::panel_run_dialog", function () {
|
||||
getRunDialog().open();
|
||||
});
|
||||
|
||||
overview = new Overview.Overview();
|
||||
chrome = new Chrome.Chrome();
|
||||
@ -229,18 +211,9 @@ function _findModal(actor) {
|
||||
* Next, record the current Clutter keyboard focus on a stack. If the modal stack
|
||||
* returns to this actor, reset the focus to the actor which was focused
|
||||
* at the time pushModal() was invoked.
|
||||
*
|
||||
* Returns: true iff we successfully acquired a grab or already had one
|
||||
*/
|
||||
function pushModal(actor) {
|
||||
if (modalCount == 0) {
|
||||
if (!global.begin_modal(currentTime())) {
|
||||
log("pushModal: invocation of begin_modal failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
global.set_stage_input_mode(Shell.StageInputMode.FULLSCREEN);
|
||||
let timestamp = global.screen.get_display().get_current_time();
|
||||
|
||||
modalCount += 1;
|
||||
actor.connect('destroy', function() {
|
||||
@ -258,7 +231,14 @@ function pushModal(actor) {
|
||||
}
|
||||
modalActorFocusStack.push([actor, curFocus]);
|
||||
|
||||
return true;
|
||||
if (modalCount > 1)
|
||||
return;
|
||||
|
||||
if (!global.begin_modal(timestamp)) {
|
||||
log("pushModal: invocation of begin_modal failed");
|
||||
return;
|
||||
}
|
||||
global.set_stage_input_mode(Shell.StageInputMode.FULLSCREEN);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -270,6 +250,8 @@ function pushModal(actor) {
|
||||
* previous focus at the time when pushModal() was invoked.
|
||||
*/
|
||||
function popModal(actor) {
|
||||
let timestamp = global.screen.get_display().get_current_time();
|
||||
|
||||
modalCount -= 1;
|
||||
let focusIndex = _findModal(actor);
|
||||
if (focusIndex >= 0) {
|
||||
@ -287,7 +269,7 @@ function popModal(actor) {
|
||||
if (modalCount > 0)
|
||||
return;
|
||||
|
||||
global.end_modal(currentTime());
|
||||
global.end_modal(timestamp);
|
||||
global.set_stage_input_mode(Shell.StageInputMode.NORMAL);
|
||||
}
|
||||
|
||||
@ -307,62 +289,15 @@ function getRunDialog() {
|
||||
}
|
||||
|
||||
function createAppLaunchContext() {
|
||||
let screen = global.screen;
|
||||
let display = screen.get_display();
|
||||
|
||||
let context = new Gdk.AppLaunchContext();
|
||||
context.set_timestamp(currentTime());
|
||||
context.set_timestamp(display.get_current_time());
|
||||
|
||||
// Make sure that the app is opened on the current workspace even if
|
||||
// the user switches before it starts
|
||||
context.set_desktop(global.screen.get_active_workspace_index());
|
||||
context.set_desktop(screen.get_active_workspace_index());
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* currentTime:
|
||||
*
|
||||
* Gets the current X server time from the current Clutter, Gdk, or X
|
||||
* event. If called from outside an event handler, this may return
|
||||
* %Clutter.CURRENT_TIME (aka 0), or it may return a slightly
|
||||
* out-of-date timestamp.
|
||||
*/
|
||||
function currentTime() {
|
||||
// meta_display_get_current_time() will return the correct time
|
||||
// when handling an X or Gdk event, but will return CurrentTime
|
||||
// from some Clutter event callbacks.
|
||||
//
|
||||
// clutter_get_current_event_time() will return the correct time
|
||||
// from a Clutter event callback, but may return an out-of-date
|
||||
// timestamp if called at other times.
|
||||
//
|
||||
// So we try meta_display_get_current_time() first, since we
|
||||
// can recognize a "wrong" answer from that, and then fall back
|
||||
// to clutter_get_current_event_time().
|
||||
|
||||
let time = global.screen.get_display().get_current_time();
|
||||
if (time != Clutter.CURRENT_TIME)
|
||||
return time;
|
||||
|
||||
return Clutter.get_current_event_time();
|
||||
}
|
||||
|
||||
/**
|
||||
* activateWindow:
|
||||
* @window: the Meta.Window to activate
|
||||
* @time: (optional) current event time
|
||||
*
|
||||
* Activates @window, switching to its workspace first if necessary
|
||||
*/
|
||||
function activateWindow(window, time) {
|
||||
let activeWorkspaceNum = global.screen.get_active_workspace_index();
|
||||
let windowWorkspaceNum = window.get_workspace().index();
|
||||
|
||||
if (!time)
|
||||
time = currentTime();
|
||||
|
||||
if (windowWorkspaceNum != activeWorkspaceNum) {
|
||||
let workspace = global.screen.get_workspace_by_index(windowWorkspaceNum);
|
||||
workspace.activate_with_focus(window, time);
|
||||
} else {
|
||||
window.activate(time);
|
||||
}
|
||||
}
|
||||
|
@ -39,10 +39,6 @@ const ANIMATION_TIME = 0.25;
|
||||
// will take up the remaining sections of the display.
|
||||
|
||||
const WIDE_SCREEN_CUT_OFF_RATIO = 1.4;
|
||||
// A common netbook resolution is 1024x600, which trips the widescreen
|
||||
// ratio. However that leaves way too few pixels for the dash. So
|
||||
// just treat this as a regular screen.
|
||||
const WIDE_SCREEN_MINIMUM_HEIGHT = 768;
|
||||
|
||||
const COLUMNS_REGULAR_SCREEN = 4;
|
||||
const ROWS_REGULAR_SCREEN = 8;
|
||||
@ -142,8 +138,7 @@ Overview.prototype = {
|
||||
},
|
||||
|
||||
_recalculateGridSizes: function () {
|
||||
wideScreen = (global.screen_width/global.screen_height > WIDE_SCREEN_CUT_OFF_RATIO) &&
|
||||
(global.screen_height >= WIDE_SCREEN_MINIMUM_HEIGHT);
|
||||
wideScreen = (global.screen_width/global.screen_height > WIDE_SCREEN_CUT_OFF_RATIO);
|
||||
|
||||
// We divide the screen into an imaginary grid which helps us determine the layout of
|
||||
// different visual components.
|
||||
@ -282,8 +277,7 @@ Overview.prototype = {
|
||||
show : function() {
|
||||
if (this.visible)
|
||||
return;
|
||||
if (!Main.pushModal(this._dash.actor))
|
||||
return;
|
||||
Main.pushModal(this._dash.actor);
|
||||
|
||||
this.visible = true;
|
||||
this.animationInProgress = true;
|
||||
@ -447,7 +441,7 @@ Overview.prototype = {
|
||||
},
|
||||
|
||||
_addNewWorkspace: function() {
|
||||
global.screen.append_new_workspace(false, Main.currentTime());
|
||||
global.screen.append_new_workspace(false, global.screen.get_display().get_current_time());
|
||||
},
|
||||
|
||||
_acceptNewWorkspaceDrop: function(source, dropActor, x, y, time) {
|
||||
|
@ -11,9 +11,11 @@ const Signals = imports.signals;
|
||||
const Gettext = imports.gettext.domain('gnome-shell');
|
||||
const _ = Gettext.gettext;
|
||||
|
||||
const Lightbox = imports.ui.lightbox;
|
||||
const Main = imports.ui.main;
|
||||
|
||||
const OVERLAY_COLOR = new Clutter.Color();
|
||||
OVERLAY_COLOR.from_pixel(0x00000044);
|
||||
|
||||
const BOX_BACKGROUND_COLOR = new Clutter.Color();
|
||||
BOX_BACKGROUND_COLOR.from_pixel(0x000000cc);
|
||||
|
||||
@ -34,8 +36,9 @@ RunDialog.prototype = {
|
||||
this._isOpen = false;
|
||||
|
||||
let gconf = Shell.GConf.get_default();
|
||||
gconf.connect('changed::development_tools', Lang.bind(this, function () {
|
||||
this._enableInternalCommands = gconf.get_boolean('development_tools');
|
||||
gconf.connect('changed', Lang.bind(this, function (gconf, key) {
|
||||
if (key == 'development_tools')
|
||||
this._enableInternalCommands = gconf.get_bool('development_tools');
|
||||
}));
|
||||
this._enableInternalCommands = gconf.get_boolean('development_tools');
|
||||
|
||||
@ -63,7 +66,12 @@ RunDialog.prototype = {
|
||||
this._group = new Clutter.Group({ visible: false });
|
||||
global.stage.add_actor(this._group);
|
||||
|
||||
this._lightbox = new Lightbox.Lightbox(this._group);
|
||||
this._overlay = new Clutter.Rectangle({ color: OVERLAY_COLOR,
|
||||
width: global.screen_width,
|
||||
height: global.screen_height,
|
||||
border_width: 0,
|
||||
reactive: true });
|
||||
this._group.add_actor(this._overlay);
|
||||
|
||||
let boxH = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL,
|
||||
x_align: Big.BoxAlignment.CENTER,
|
||||
@ -72,7 +80,6 @@ RunDialog.prototype = {
|
||||
height: global.screen_height });
|
||||
|
||||
this._group.add_actor(boxH);
|
||||
this._lightbox.highlight(boxH);
|
||||
|
||||
let boxV = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL,
|
||||
y_align: Big.BoxAlignment.CENTER });
|
||||
@ -179,12 +186,10 @@ RunDialog.prototype = {
|
||||
if (this._isOpen) // Already shown
|
||||
return;
|
||||
|
||||
if (!Main.pushModal(this._group))
|
||||
return;
|
||||
|
||||
this._isOpen = true;
|
||||
this._group.show();
|
||||
|
||||
Main.pushModal(this._group);
|
||||
global.stage.set_key_focus(this._entry);
|
||||
},
|
||||
|
||||
|
@ -1,72 +0,0 @@
|
||||
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
|
||||
|
||||
const DBus = imports.dbus;
|
||||
const Lang = imports.lang;
|
||||
const Shell = imports.gi.Shell;
|
||||
const Mainloop = imports.mainloop;
|
||||
|
||||
const Main = imports.ui.main;
|
||||
|
||||
const GnomeShellIface = {
|
||||
name: "org.gnome.Shell",
|
||||
methods: [{ name: "Eval",
|
||||
inSignature: "s",
|
||||
outSignature: "bs"
|
||||
}
|
||||
],
|
||||
signals: [],
|
||||
properties: [{ name: "OverviewActive",
|
||||
signature: "b",
|
||||
access: "readwrite" }]
|
||||
};
|
||||
|
||||
function GnomeShell() {
|
||||
this._init();
|
||||
}
|
||||
|
||||
GnomeShell.prototype = {
|
||||
_init: function() {
|
||||
DBus.session.exportObject('/org/gnome/Shell', this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Eval:
|
||||
* @code: A string containing JavaScript code
|
||||
*
|
||||
* This function executes arbitrary code in the main
|
||||
* loop, and returns a boolean success and
|
||||
* JSON representation of the object as a string.
|
||||
*
|
||||
* If evaluation completes without throwing an exception,
|
||||
* then the return value will be [true, JSON.stringify(result)].
|
||||
* If evaluation fails, then the return value will be
|
||||
* [false, JSON.stringify(exception)];
|
||||
*
|
||||
*/
|
||||
Eval: function(code) {
|
||||
let returnValue;
|
||||
let success;
|
||||
try {
|
||||
returnValue = JSON.stringify(eval(code));
|
||||
success = true;
|
||||
} catch (e) {
|
||||
returnValue = JSON.stringify(e);
|
||||
success = false;
|
||||
}
|
||||
return [success, returnValue];
|
||||
},
|
||||
|
||||
get OverviewActive() {
|
||||
return Main.overview.visible;
|
||||
},
|
||||
|
||||
set OverviewActive(visible) {
|
||||
if (visible)
|
||||
Main.overview.show();
|
||||
else
|
||||
Main.overview.hide();
|
||||
}
|
||||
};
|
||||
|
||||
DBus.conformExport(GnomeShell.prototype, GnomeShellIface);
|
||||
|
@ -4,7 +4,6 @@ const Clutter = imports.gi.Clutter;
|
||||
const Lang = imports.lang;
|
||||
const Mainloop = imports.mainloop;
|
||||
const Meta = imports.gi.Meta;
|
||||
const Shell = imports.gi.Shell;
|
||||
|
||||
const AltTab = imports.ui.altTab;
|
||||
const Main = imports.ui.main;
|
||||
@ -40,8 +39,7 @@ WindowManager.prototype = {
|
||||
shellwm.connect('destroy', Lang.bind(this, this._destroyWindow));
|
||||
shellwm.connect('kill-destroy', Lang.bind(this, this._destroyWindowDone));
|
||||
|
||||
shellwm.takeover_keybinding('switch_windows');
|
||||
shellwm.connect('keybinding::switch_windows', Lang.bind(this, this._startAppSwitcher));
|
||||
shellwm.connect('begin-alt-tab', Lang.bind(this, this._beginAltTab));
|
||||
},
|
||||
|
||||
_shouldAnimate : function(actor) {
|
||||
@ -163,10 +161,41 @@ WindowManager.prototype = {
|
||||
},
|
||||
|
||||
_destroyWindow : function(shellwm, actor) {
|
||||
shellwm.completed_destroy(actor);
|
||||
if (!this._shouldAnimate(actor)) {
|
||||
shellwm.completed_destroy(actor);
|
||||
return;
|
||||
}
|
||||
|
||||
actor.move_anchor_point_from_gravity(Clutter.Gravity.CENTER);
|
||||
|
||||
/* anachronistic 'tv-like' effect - squash on y axis, leave x alone */
|
||||
this._destroying.push(actor);
|
||||
Tweener.addTween(actor,
|
||||
{ scale_x: 1.0,
|
||||
scale_y: 0.0,
|
||||
time: WINDOW_ANIMATION_TIME,
|
||||
transition: "easeOutQuad",
|
||||
onComplete: this._destroyWindowDone,
|
||||
onCompleteScope: this,
|
||||
onCompleteParams: [shellwm, actor],
|
||||
onOverwrite: this._destroyWindowOverwrite,
|
||||
onOverwriteScope: this,
|
||||
onOverwriteParams: [shellwm, actor]
|
||||
});
|
||||
},
|
||||
|
||||
_destroyWindowDone : function(shellwm, actor) {
|
||||
if (this._removeEffect(this._destroying, actor)) {
|
||||
shellwm.completed_destroy(actor);
|
||||
Tweener.removeTweens(actor);
|
||||
actor.set_scale(1.0, 1.0);
|
||||
}
|
||||
},
|
||||
|
||||
_destroyWindowOverwrite : function(shellwm, actor) {
|
||||
if (this._removeEffect(this._destroying, actor)) {
|
||||
shellwm.completed_destroy(actor);
|
||||
}
|
||||
},
|
||||
|
||||
_switchWorkspace : function(shellwm, from, to, direction) {
|
||||
@ -271,10 +300,12 @@ WindowManager.prototype = {
|
||||
shellwm.completed_switch_workspace();
|
||||
},
|
||||
|
||||
_startAppSwitcher : function(shellwm, binding, window, backwards) {
|
||||
let tabPopup = new AltTab.AltTabPopup();
|
||||
_beginAltTab : function(shellwm, handler) {
|
||||
let popup = new AltTab.AltTabPopup();
|
||||
|
||||
if (!tabPopup.show(backwards ? -1 : 1))
|
||||
tabPopup.destroy();
|
||||
}
|
||||
handler.connect('window-added', function(handler, window) { popup.addWindow(window); });
|
||||
handler.connect('show', function(handler, initialSelection) { popup.show(initialSelection); });
|
||||
handler.connect('destroy', function() { popup.destroy(); });
|
||||
handler.connect('notify::selected', function() { popup.select(handler.selected); });
|
||||
}
|
||||
};
|
||||
|
@ -12,7 +12,6 @@ const Shell = imports.gi.Shell;
|
||||
const Signals = imports.signals;
|
||||
|
||||
const DND = imports.ui.dnd;
|
||||
const Lightbox = imports.ui.lightbox;
|
||||
const Main = imports.ui.main;
|
||||
const Overview = imports.ui.overview;
|
||||
const Panel = imports.ui.panel;
|
||||
@ -26,6 +25,8 @@ const WINDOWCLONE_TITLE_COLOR = new Clutter.Color();
|
||||
WINDOWCLONE_TITLE_COLOR.from_pixel(0xffffffff);
|
||||
const FRAME_COLOR = new Clutter.Color();
|
||||
FRAME_COLOR.from_pixel(0xffffffff);
|
||||
const LIGHTBOX_COLOR = new Clutter.Color();
|
||||
LIGHTBOX_COLOR.from_pixel(0x00000044);
|
||||
|
||||
const SCROLL_SCALE_AMOUNT = 100 / 5;
|
||||
|
||||
@ -44,8 +45,7 @@ const POSITIONS = {
|
||||
4: [[0.25, 0.25, 0.47], [0.75, 0.25, 0.47], [0.75, 0.75, 0.47], [0.25, 0.75, 0.47]],
|
||||
5: [[0.165, 0.25, 0.32], [0.495, 0.25, 0.32], [0.825, 0.25, 0.32], [0.25, 0.75, 0.32], [0.75, 0.75, 0.32]]
|
||||
};
|
||||
// Used in _orderWindowsPermutations, 5! = 120 which is probably the highest we can go
|
||||
const POSITIONING_PERMUTATIONS_MAX = 5;
|
||||
|
||||
|
||||
function _interpolate(start, end, step) {
|
||||
return start + (end - start) * step;
|
||||
@ -206,17 +206,33 @@ WindowClone.prototype = {
|
||||
},
|
||||
|
||||
_zoomStart : function () {
|
||||
this._zoomLightbox = new Lightbox.Lightbox(global.stage);
|
||||
this._zoomOverlay = new Clutter.Rectangle({ reactive: true,
|
||||
color: LIGHTBOX_COLOR,
|
||||
border_width: 0,
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: global.screen_width,
|
||||
height: global.screen_height,
|
||||
opacity: 0 });
|
||||
this._zoomOverlay.show();
|
||||
global.stage.add_actor(this._zoomOverlay);
|
||||
Tweener.addTween(this._zoomOverlay,
|
||||
{ opacity: 255,
|
||||
time: ZOOM_OVERLAY_FADE_TIME,
|
||||
transition: "easeOutQuad"
|
||||
});
|
||||
|
||||
this._zoomLocalOrig = new ScaledPoint(this.actor.x, this.actor.y, this.actor.scale_x, this.actor.scale_y);
|
||||
this._zoomGlobalOrig = new ScaledPoint();
|
||||
let parent = this._origParent = this.actor.get_parent();
|
||||
let [width, height] = this.actor.get_transformed_size();
|
||||
[width, height] = this.actor.get_transformed_size();
|
||||
this._zoomGlobalOrig.setPosition.apply(this._zoomGlobalOrig, this.actor.get_transformed_position());
|
||||
this._zoomGlobalOrig.setScale(width / this.actor.width, height / this.actor.height);
|
||||
|
||||
this._zoomOverlay.raise_top();
|
||||
this._zoomOverlay.show();
|
||||
|
||||
this.actor.reparent(global.stage);
|
||||
this._zoomLightbox.highlight(this.actor);
|
||||
|
||||
[this.actor.x, this.actor.y] = this._zoomGlobalOrig.getPosition();
|
||||
[this.actor.scale_x, this.actor.scale_y] = this._zoomGlobalOrig.getScale();
|
||||
@ -239,7 +255,7 @@ WindowClone.prototype = {
|
||||
|
||||
this._adjustTitle();
|
||||
|
||||
this._zoomLightbox.destroy();
|
||||
this._zoomOverlay.destroy();
|
||||
Main.overview.disconnect(this._hideEventId);
|
||||
|
||||
this._zoomLocalPosition = undefined;
|
||||
@ -247,8 +263,8 @@ WindowClone.prototype = {
|
||||
this._zoomGlobalPosition = undefined;
|
||||
this._zoomGlobalScale = undefined;
|
||||
this._zoomTargetPosition = undefined;
|
||||
this._zoomStep = undefined;
|
||||
this._zoomLightbox = undefined;
|
||||
this._zoomStep = undefined;
|
||||
this._zoomOverlay = undefined;
|
||||
},
|
||||
|
||||
_onButtonRelease : function (actor, event) {
|
||||
@ -415,6 +431,14 @@ Workspace.prototype = {
|
||||
this.actor.height = global.screen_height;
|
||||
this.scale = 1.0;
|
||||
|
||||
this._lightbox = new Clutter.Rectangle({ color: LIGHTBOX_COLOR });
|
||||
this.actor.connect('notify::allocation', Lang.bind(this, function () {
|
||||
let [width, height] = this.actor.get_size();
|
||||
this._lightbox.set_size(width, height);
|
||||
}));
|
||||
this.actor.add_actor(this._lightbox);
|
||||
this._lightbox.hide();
|
||||
|
||||
let windows = global.get_windows().filter(this._isMyWindow, this);
|
||||
|
||||
// Find the desktop window
|
||||
@ -549,10 +573,10 @@ Workspace.prototype = {
|
||||
*/
|
||||
setLightboxMode: function (showLightbox) {
|
||||
if (showLightbox) {
|
||||
this._lightbox = new Lightbox.Lightbox(this.actor);
|
||||
this.setHighlightWindow(null);
|
||||
this._lightbox.show();
|
||||
} else {
|
||||
this._lightbox.destroy();
|
||||
this._lightbox = null;
|
||||
this._lightbox.hide();
|
||||
}
|
||||
},
|
||||
|
||||
@ -563,12 +587,13 @@ Workspace.prototype = {
|
||||
* Draw the user's attention to the given window @metaWindow.
|
||||
*/
|
||||
setHighlightWindow: function (metaWindow) {
|
||||
let actor;
|
||||
for (let i = 0; i < this._windows.length; i++) {
|
||||
this._windows[i].actor.lower(this._lightbox);
|
||||
}
|
||||
if (metaWindow != null) {
|
||||
let clone = this.lookupCloneForMetaWindow(metaWindow);
|
||||
actor = clone.actor;
|
||||
clone.actor.raise(this._lightbox);
|
||||
}
|
||||
this._lightbox.highlight(actor);
|
||||
},
|
||||
|
||||
_adjustRemoveButton : function() {
|
||||
@ -632,220 +657,6 @@ Workspace.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
// Only use this for n <= 20 say
|
||||
_factorial: function(n) {
|
||||
let result = 1;
|
||||
for (let i = 2; i <= n; i++)
|
||||
result *= i;
|
||||
return result;
|
||||
},
|
||||
|
||||
/**
|
||||
* _permutation:
|
||||
* @permutationIndex: An integer from [0, list.length!)
|
||||
* @list: (inout): Array of objects to permute; will be modified in place
|
||||
*
|
||||
* Given an integer between 0 and length of array, re-order the array in-place
|
||||
* into a permutation denoted by the index.
|
||||
*/
|
||||
_permutation: function(permutationIndex, list) {
|
||||
for (let j = 2; j <= list.length; j++) {
|
||||
let firstIndex = (permutationIndex % j);
|
||||
let secondIndex = j - 1;
|
||||
// Swap
|
||||
let tmp = list[firstIndex];
|
||||
list[firstIndex] = list[secondIndex];
|
||||
list[secondIndex] = tmp;
|
||||
permutationIndex = Math.floor(permutationIndex / j);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* _forEachPermutations:
|
||||
* @list: Array
|
||||
* @func: Function which takes a single array argument
|
||||
*
|
||||
* Call @func with each permutation of @list as an argument.
|
||||
*/
|
||||
_forEachPermutations: function(list, func) {
|
||||
let nCombinations = this._factorial(list.length);
|
||||
for (let i = 0; i < nCombinations; i++) {
|
||||
let listCopy = list.concat();
|
||||
this._permutation(i, listCopy);
|
||||
func(listCopy);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* _computeWindowMotion:
|
||||
* @metaWindow: A #MetaWindow
|
||||
* @slot: An element of #POSITIONS
|
||||
* @slotGeometry: Layout of @slot
|
||||
*
|
||||
* Returns a number corresponding to how much perceived motion
|
||||
* would be involved in moving the window to the given slot.
|
||||
* Currently this is the square of the distance between the
|
||||
* centers.
|
||||
*/
|
||||
_computeWindowMotion: function (metaWindow, slot, slotGeometry) {
|
||||
let rect = new Meta.Rectangle();
|
||||
metaWindow.get_outer_rect(rect);
|
||||
|
||||
let [slotX, slotY, slotWidth, slotHeight] = slotGeometry;
|
||||
let distanceSquared;
|
||||
let xDelta, yDelta;
|
||||
|
||||
xDelta = (rect.x + rect.width / 2) - (slotX + slotWidth / 2);
|
||||
yDelta = (rect.y + rect.height / 2) - (slotY + slotHeight / 2);
|
||||
distanceSquared = xDelta * xDelta + yDelta * yDelta;
|
||||
|
||||
return distanceSquared;
|
||||
},
|
||||
|
||||
/**
|
||||
* _orderWindowsPermutations:
|
||||
*
|
||||
* Iterate over all permutations of the windows, and determine the
|
||||
* permutation which has the least total motion.
|
||||
*/
|
||||
_orderWindowsPermutations: function (windows, slots, slotGeometries) {
|
||||
let minimumMotionPermutation = null;
|
||||
let minimumMotion = -1;
|
||||
let permIndex = 0;
|
||||
this._forEachPermutations(windows, Lang.bind(this, function (permutation) {
|
||||
let motion = 0;
|
||||
for (let i = 0; i < permutation.length; i++) {
|
||||
let metaWindow = permutation[i];
|
||||
let slot = slots[i];
|
||||
let slotAbsGeometry = slotGeometries[i];
|
||||
|
||||
let delta = this._computeWindowMotion(metaWindow, slot, slotAbsGeometry);
|
||||
|
||||
motion += delta;
|
||||
}
|
||||
|
||||
if (minimumMotionPermutation == null || motion < minimumMotion) {
|
||||
minimumMotionPermutation = permutation;
|
||||
minimumMotion = motion;
|
||||
}
|
||||
permIndex++;
|
||||
}));
|
||||
return minimumMotionPermutation;
|
||||
},
|
||||
|
||||
/**
|
||||
* _orderWindowsGreedy:
|
||||
*
|
||||
* Iterate over available slots in order, placing into each one the window
|
||||
* we find with the smallest motion to that slot.
|
||||
*/
|
||||
_orderWindowsGreedy: function(windows, slots, slotGeometries) {
|
||||
let result = [];
|
||||
let slotIndex = 0;
|
||||
// Copy since we mutate below
|
||||
let windowCopy = windows.concat();
|
||||
for (let i = 0; i < slots.length; i++) {
|
||||
let slot = slots[i];
|
||||
let slotGeometry = slotGeometries[i];
|
||||
let minimumMotionIndex = -1;
|
||||
let minimumMotion = -1;
|
||||
for (let j = 0; j < windowCopy.length; j++) {
|
||||
let metaWindow = windowCopy[j];
|
||||
let delta = this._computeWindowMotion(metaWindow, slot, slotGeometry);
|
||||
if (minimumMotionIndex == -1 || delta < minimumMotion) {
|
||||
minimumMotionIndex = j;
|
||||
minimumMotion = delta;
|
||||
}
|
||||
}
|
||||
result.push(windowCopy[minimumMotionIndex]);
|
||||
windowCopy.splice(minimumMotionIndex, 1);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
/**
|
||||
* _orderWindowsByMotionAndStartup:
|
||||
* @windows: Array of #MetaWindow
|
||||
* @slots: Array of slots
|
||||
*
|
||||
* Returns a copy of @windows, ordered in such a way that they require least motion
|
||||
* to move to the final screen coordinates of @slots. Ties are broken in a stable
|
||||
* fashion by the order in which the windows were created.
|
||||
*/
|
||||
_orderWindowsByMotionAndStartup: function(windows, slots) {
|
||||
let appMonitor = Shell.AppMonitor.get_default();
|
||||
windows.sort(function(w1, w2) {
|
||||
return w2.get_stable_sequence() - w1.get_stable_sequence();
|
||||
});
|
||||
let slotGeometries = slots.map(Lang.bind(this, this._getSlotAbsoluteGeometry));
|
||||
if (windows.length <= POSITIONING_PERMUTATIONS_MAX)
|
||||
return this._orderWindowsPermutations(windows, slots, slotGeometries);
|
||||
else
|
||||
return this._orderWindowsGreedy(windows, slots, slotGeometries);
|
||||
},
|
||||
|
||||
/**
|
||||
* _getSlotRelativeGeometry:
|
||||
* @slot: A layout slot
|
||||
*
|
||||
* Returns: the workspace-relative [x, y, width, height]
|
||||
* of a given window layout slot.
|
||||
*/
|
||||
_getSlotRelativeGeometry: function(slot) {
|
||||
let [xCenter, yCenter, fraction] = slot;
|
||||
|
||||
let width = global.screen_width * fraction;
|
||||
let height = global.screen_height * fraction;
|
||||
|
||||
let x = xCenter * global.screen_width - width / 2;
|
||||
let y = yCenter * global.screen_height - height / 2;
|
||||
|
||||
return [x, y, width, height];
|
||||
},
|
||||
|
||||
/**
|
||||
* _getSlotAbsoluteGeometry:
|
||||
* @slot: A layout slot
|
||||
*
|
||||
* Returns: the screen coordiantes [x, y, width, height]
|
||||
* of a given window layout slot.
|
||||
*/
|
||||
_getSlotAbsoluteGeometry: function(slot) {
|
||||
let [x, y, width, height] = this._getSlotRelativeGeometry(slot);
|
||||
return [ this.gridX + x, this.gridY + y,
|
||||
this.scale * width, this.scale * height];
|
||||
},
|
||||
|
||||
/**
|
||||
* _computeWindowRelativeLayout:
|
||||
* @metaWindow: A #MetaWindow
|
||||
* @slot: A layout slot
|
||||
*
|
||||
* Given a window and slot to fit it in, compute its
|
||||
* workspace-relative [x, y, scale] where scale applies
|
||||
* to both X and Y directions.
|
||||
*/
|
||||
_computeWindowRelativeLayout: function(metaWindow, slot) {
|
||||
let [xCenter, yCenter, fraction] = slot;
|
||||
|
||||
xCenter = xCenter * global.screen_width;
|
||||
yCenter = yCenter * global.screen_height;
|
||||
|
||||
let rect = new Meta.Rectangle();
|
||||
metaWindow.get_outer_rect(rect);
|
||||
|
||||
let desiredWidth = global.screen_width * fraction;
|
||||
let desiredHeight = global.screen_height * fraction;
|
||||
let scale = Math.min(desiredWidth / rect.width,
|
||||
desiredHeight / rect.height,
|
||||
1.0 / this.scale);
|
||||
|
||||
let x = xCenter - 0.5 * scale * rect.width;
|
||||
let y = yCenter - 0.5 * scale * rect.height;
|
||||
|
||||
return [x, y, scale];
|
||||
},
|
||||
|
||||
/**
|
||||
* positionWindows:
|
||||
* @workspaceZooming: If true, then the workspace is moving at the same time and we need to take that into account.
|
||||
@ -853,37 +664,47 @@ Workspace.prototype = {
|
||||
positionWindows : function(workspaceZooming) {
|
||||
let totalVisible = 0;
|
||||
|
||||
let visibleWindows = [];
|
||||
|
||||
for (let i = 1; i < this._windows.length; i++) {
|
||||
let clone = this._windows[i];
|
||||
|
||||
if (this._showOnlyWindows != null && !(clone.metaWindow in this._showOnlyWindows))
|
||||
continue;
|
||||
|
||||
visibleWindows.push(clone.metaWindow);
|
||||
totalVisible += 1;
|
||||
}
|
||||
|
||||
let slots = this._computeAllWindowSlots(visibleWindows.length);
|
||||
visibleWindows = this._orderWindowsByMotionAndStartup(visibleWindows, slots);
|
||||
|
||||
let previousWindow = this._windows[0];
|
||||
for (let i = 0; i < visibleWindows.length; i++) {
|
||||
let slot = slots[i];
|
||||
let metaWindow = visibleWindows[i];
|
||||
let mainIndex = this._lookupIndex(metaWindow);
|
||||
let clone = metaWindow._delegate;
|
||||
let icon = this._windowIcons[mainIndex];
|
||||
let visibleIndex = 0;
|
||||
for (let i = 1; i < this._windows.length; i++) {
|
||||
let clone = this._windows[i];
|
||||
let icon = this._windowIcons[i];
|
||||
|
||||
if (this._showOnlyWindows != null && !(clone.metaWindow in this._showOnlyWindows))
|
||||
continue;
|
||||
|
||||
clone.stackAbove = previousWindow.actor;
|
||||
previousWindow = clone;
|
||||
|
||||
let [x, y, scale] = this._computeWindowRelativeLayout(metaWindow, slot);
|
||||
visibleIndex += 1;
|
||||
|
||||
let [xCenter, yCenter, fraction] = this._computeWindowPosition(visibleIndex, totalVisible);
|
||||
xCenter = xCenter * global.screen_width;
|
||||
yCenter = yCenter * global.screen_height;
|
||||
|
||||
// clone.actor.width/height aren't reliably set at this point for
|
||||
// a new window - they're only set when the window contents are
|
||||
// initially updated prior to painting.
|
||||
let cloneRect = new Meta.Rectangle();
|
||||
clone.realWindow.meta_window.get_outer_rect(cloneRect);
|
||||
|
||||
let desiredWidth = global.screen_width * fraction;
|
||||
let desiredHeight = global.screen_height * fraction;
|
||||
let scale = Math.min(desiredWidth / cloneRect.width, desiredHeight / cloneRect.height, 1.0 / this.scale);
|
||||
|
||||
icon.hide();
|
||||
Tweener.addTween(clone.actor,
|
||||
{ x: x,
|
||||
y: y,
|
||||
Tweener.addTween(clone.actor,
|
||||
{ x: xCenter - 0.5 * scale * cloneRect.width,
|
||||
y: yCenter - 0.5 * scale * cloneRect.height,
|
||||
scale_x: scale,
|
||||
scale_y: scale,
|
||||
workspace_relative: workspaceZooming ? this : null,
|
||||
@ -1211,7 +1032,11 @@ Workspace.prototype = {
|
||||
return clone;
|
||||
},
|
||||
|
||||
_computeWindowSlot : function(windowIndex, numberOfWindows) {
|
||||
_computeWindowPosition : function(index, totalWindows) {
|
||||
// ignore this._windows[0], which is the desktop
|
||||
let windowIndex = index - 1;
|
||||
let numberOfWindows = totalWindows;
|
||||
|
||||
if (numberOfWindows in POSITIONS)
|
||||
return POSITIONS[numberOfWindows][windowIndex];
|
||||
|
||||
@ -1228,14 +1053,6 @@ Workspace.prototype = {
|
||||
return [xCenter, yCenter, fraction];
|
||||
},
|
||||
|
||||
_computeAllWindowSlots: function(totalWindows) {
|
||||
let slots = [];
|
||||
for (let i = 0; i < totalWindows; i++) {
|
||||
slots.push(this._computeWindowSlot(i, totalWindows));
|
||||
}
|
||||
return slots;
|
||||
},
|
||||
|
||||
_onCloneSelected : function (clone, time) {
|
||||
Main.overview.activateWindow(clone.metaWindow, time);
|
||||
},
|
||||
@ -1409,6 +1226,21 @@ Workspaces.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
_activateWindowInternal: function (metaWindow, time) {
|
||||
let activeWorkspaceNum = global.screen.get_active_workspace_index();
|
||||
let windowWorkspaceNum = metaWindow.get_workspace().index();
|
||||
|
||||
let clone = this._lookupCloneForMetaWindow (metaWindow);
|
||||
clone.actor.raise_top();
|
||||
|
||||
if (windowWorkspaceNum != activeWorkspaceNum) {
|
||||
let workspace = global.screen.get_workspace_by_index(windowWorkspaceNum);
|
||||
workspace.activate_with_focus(metaWindow, time);
|
||||
} else {
|
||||
metaWindow.activate(time);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* activateWindowFromOverview:
|
||||
* @metaWindow: A #MetaWindow
|
||||
@ -1421,11 +1253,7 @@ Workspaces.prototype = {
|
||||
if (this._windowSelectionAppId != null) {
|
||||
this._clearApplicationWindowSelection(false);
|
||||
}
|
||||
|
||||
let clone = this._lookupCloneForMetaWindow (metaWindow);
|
||||
clone.actor.raise_top();
|
||||
|
||||
Main.activateWindow(metaWindow, time);
|
||||
this._activateWindowInternal(metaWindow, time);
|
||||
Main.overview.hide();
|
||||
},
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
ar
|
||||
ca
|
||||
cs
|
||||
da
|
||||
@ -16,7 +15,6 @@ nl
|
||||
pa
|
||||
pl
|
||||
pt_BR
|
||||
sl
|
||||
sv
|
||||
tr
|
||||
zh_CN
|
||||
|
201
po/ar.po
201
po/ar.po
@ -1,201 +0,0 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# Khaled Hosny <khaledhosny@eglug.org>, 2009.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: HEAD\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-09-25 04:22+0200\n"
|
||||
"PO-Revision-Date: 2009-09-25 04:21+0300\n"
|
||||
"Last-Translator: Khaled Hosny <khaledhosny@eglug.org>\n"
|
||||
"Language-Team: Arabic <doc@arabeyes.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Language: ar\n"
|
||||
"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 "
|
||||
"&& n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n"
|
||||
"X-Generator: Virtaal 0.4.0\n"
|
||||
|
||||
#: ../data/gnome-shell.desktop.in.in.h:1
|
||||
msgid "GNOME Shell"
|
||||
msgstr "صدفة جنوم"
|
||||
|
||||
#: ../data/gnome-shell.desktop.in.in.h:2
|
||||
msgid "Window management and application launching"
|
||||
msgstr "إدارة النوافذ وإطلاق التطبيقات"
|
||||
|
||||
#. left side
|
||||
#: ../js/ui/panel.js:269
|
||||
msgid "Activities"
|
||||
msgstr "الأنشطة"
|
||||
|
||||
#. Translators: This is a time format.
|
||||
#: ../js/ui/panel.js:452
|
||||
msgid "%a %l:%M %p"
|
||||
msgstr "%A %Ol:%OM %p"
|
||||
|
||||
#: ../js/ui/dash.js:283
|
||||
msgid "Find..."
|
||||
msgstr "ابحث..."
|
||||
|
||||
#: ../js/ui/dash.js:400
|
||||
msgid "Browse"
|
||||
msgstr "استعرض"
|
||||
|
||||
#: ../js/ui/dash.js:536
|
||||
msgid "(see all)"
|
||||
msgstr "(انظر الكل)"
|
||||
|
||||
#. **** Applications ****
|
||||
#: ../js/ui/dash.js:753 ../js/ui/dash.js:809
|
||||
msgid "APPLICATIONS"
|
||||
msgstr "التطبيقات"
|
||||
|
||||
#. **** Places ****
|
||||
#. Translators: This is in the sense of locations for documents,
|
||||
#. network locations, etc.
|
||||
#: ../js/ui/dash.js:773
|
||||
msgid "PLACES"
|
||||
msgstr "الأماكن"
|
||||
|
||||
#. **** Documents ****
|
||||
#: ../js/ui/dash.js:780 ../js/ui/dash.js:819
|
||||
msgid "RECENT DOCUMENTS"
|
||||
msgstr "المستندات الحديثة"
|
||||
|
||||
#. **** Search Results ****
|
||||
#: ../js/ui/dash.js:799 ../js/ui/dash.js:931
|
||||
msgid "SEARCH RESULTS"
|
||||
msgstr "نتائج البحث"
|
||||
|
||||
#: ../js/ui/dash.js:814
|
||||
msgid "PREFERENCES"
|
||||
msgstr "التفضيلات"
|
||||
|
||||
#: ../js/ui/runDialog.js:95
|
||||
msgid "Please enter a command:"
|
||||
msgstr "من فضلك اكتب أمرا:"
|
||||
|
||||
#: ../src/shell-global.c:799
|
||||
msgid "Less than a minute ago"
|
||||
msgstr "منذ أقل من دقيقة"
|
||||
|
||||
#: ../src/shell-global.c:802
|
||||
#, c-format
|
||||
msgid "%d minute ago"
|
||||
msgid_plural "%d minutes ago"
|
||||
msgstr[0] "منذ أقل من دقيقة"
|
||||
msgstr[1] "منذ دقيقة"
|
||||
msgstr[2] "منذ دقيقتين"
|
||||
msgstr[3] "منذ %d دقائق"
|
||||
msgstr[4] "منذ %d دقيقة"
|
||||
msgstr[5] "منذ %d دقيقة"
|
||||
|
||||
#: ../src/shell-global.c:805
|
||||
#, c-format
|
||||
msgid "%d hour ago"
|
||||
msgid_plural "%d hours ago"
|
||||
msgstr[0] "منذ أقل من ساعة"
|
||||
msgstr[1] "منذ ساعة"
|
||||
msgstr[2] "منذ ساعتين"
|
||||
msgstr[3] "منذ %d ساعات"
|
||||
msgstr[4] "منذ %d ساعة"
|
||||
msgstr[5] "منذ %d ساعة"
|
||||
|
||||
#: ../src/shell-global.c:808
|
||||
#, c-format
|
||||
msgid "%d day ago"
|
||||
msgid_plural "%d days ago"
|
||||
msgstr[0] "منذ أقل من يوم"
|
||||
msgstr[1] "منذ يوم"
|
||||
msgstr[2] "منذ يومين"
|
||||
msgstr[3] "منذ %d أيام"
|
||||
msgstr[4] "منذ %d يوما"
|
||||
msgstr[5] "منذ %d يوم"
|
||||
|
||||
#: ../src/shell-global.c:811
|
||||
#, c-format
|
||||
msgid "%d week ago"
|
||||
msgid_plural "%d weeks ago"
|
||||
msgstr[0] "منذ أقل من أسبوع"
|
||||
msgstr[1] "منذ أسبوع"
|
||||
msgstr[2] "منذ أسبوعين"
|
||||
msgstr[3] "منذ %d أسابيع"
|
||||
msgstr[4] "منذ %d أسبوعا"
|
||||
msgstr[5] "منذ %d أسبوع"
|
||||
|
||||
#: ../src/shell-status-menu.c:156
|
||||
msgid "Unknown"
|
||||
msgstr "مجهول"
|
||||
|
||||
#: ../src/shell-status-menu.c:212
|
||||
#, c-format
|
||||
msgid "Can't lock screen: %s"
|
||||
msgstr "تعذّر إيصاد الشاشة: %s"
|
||||
|
||||
#: ../src/shell-status-menu.c:227
|
||||
#, c-format
|
||||
msgid "Can't temporarily set screensaver to blank screen: %s"
|
||||
msgstr "تعذّر ضبك حافظة الشاشة مؤقتا لتكون شاشة خالية: %s"
|
||||
|
||||
#: ../src/shell-status-menu.c:351
|
||||
#, c-format
|
||||
msgid "Can't logout: %s"
|
||||
msgstr "تعذّر الخروج: %s"
|
||||
|
||||
#: ../src/shell-status-menu.c:492
|
||||
msgid "Account Information..."
|
||||
msgstr "معلومات الحساب..."
|
||||
|
||||
#: ../src/shell-status-menu.c:502
|
||||
msgid "Sidebar"
|
||||
msgstr "الشريط الجانبي"
|
||||
|
||||
#: ../src/shell-status-menu.c:510
|
||||
msgid "System Preferences..."
|
||||
msgstr "تفضيلات النظام..."
|
||||
|
||||
#: ../src/shell-status-menu.c:525
|
||||
msgid "Lock Screen"
|
||||
msgstr "أوصد الشاشة"
|
||||
|
||||
#: ../src/shell-status-menu.c:535
|
||||
msgid "Switch User"
|
||||
msgstr "بدّل المستخدم"
|
||||
|
||||
#. Only show switch user if there are other users
|
||||
#. Log Out
|
||||
#: ../src/shell-status-menu.c:546
|
||||
msgid "Log Out..."
|
||||
msgstr "اخرج..."
|
||||
|
||||
#. Shut down
|
||||
#: ../src/shell-status-menu.c:557
|
||||
msgid "Shut Down..."
|
||||
msgstr "أطفئ..."
|
||||
|
||||
#: ../src/shell-uri-util.c:87
|
||||
msgid "Home Folder"
|
||||
msgstr "مجلد المنزل"
|
||||
|
||||
#. Translators: this is the same string as the one found in
|
||||
#. * nautilus
|
||||
#: ../src/shell-uri-util.c:102
|
||||
msgid "File System"
|
||||
msgstr "نظام الملفات"
|
||||
|
||||
#: ../src/shell-uri-util.c:248
|
||||
msgid "Search"
|
||||
msgstr "ابحث"
|
||||
|
||||
#. Translators: the first string is the name of a gvfs
|
||||
#. * method, and the second string is a path. For
|
||||
#. * example, "Trash: some-directory". It means that the
|
||||
#. * directory called "some-directory" is in the trash.
|
||||
#.
|
||||
#: ../src/shell-uri-util.c:298
|
||||
#, c-format
|
||||
msgid "%1$s: %2$s"
|
||||
msgstr "%1$s: %2$s"
|
40
po/cs.po
40
po/cs.po
@ -7,9 +7,9 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: gnome-shell\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-09-22 13:36+0200\n"
|
||||
"PO-Revision-Date: 2009-09-22 13:37+0200\n"
|
||||
"Last-Translator: Andre Klapper <ak-47@gmx.net>, 2009\n"
|
||||
"POT-Creation-Date: 2009-08-30 17:37+0200\n"
|
||||
"PO-Revision-Date: 2009-08-30 17:33+0200\n"
|
||||
"Last-Translator: Petr Kovar <pknbe@volny.cz>\n"
|
||||
"Language-Team: Czech <gnome-cs-list@gnome.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
@ -25,62 +25,58 @@ msgid "Window management and application launching"
|
||||
msgstr "Správa oken a spouštění aplikací"
|
||||
|
||||
#. left side
|
||||
#: ../js/ui/panel.js:269
|
||||
#: ../js/ui/panel.js:271
|
||||
msgid "Activities"
|
||||
msgstr "Činnosti"
|
||||
|
||||
#. Translators: This is a time format.
|
||||
#: ../js/ui/panel.js:452
|
||||
#: ../js/ui/panel.js:454
|
||||
msgid "%a %l:%M %p"
|
||||
msgstr "%a, %H:%M"
|
||||
|
||||
#: ../js/ui/dash.js:283
|
||||
#: ../js/ui/dash.js:256
|
||||
msgid "Find..."
|
||||
msgstr "Najít..."
|
||||
|
||||
#: ../js/ui/dash.js:400
|
||||
#: ../js/ui/dash.js:374
|
||||
msgid "Browse"
|
||||
msgstr "Procházet"
|
||||
|
||||
#: ../js/ui/dash.js:536
|
||||
#: ../js/ui/dash.js:451
|
||||
msgid "(see all)"
|
||||
msgstr "(zobrazit vše)"
|
||||
|
||||
#. **** Applications ****
|
||||
#: ../js/ui/dash.js:753 ../js/ui/dash.js:809
|
||||
#: ../js/ui/dash.js:633 ../js/ui/dash.js:681
|
||||
msgid "APPLICATIONS"
|
||||
msgstr "APLIKACE"
|
||||
|
||||
#. **** Places ****
|
||||
#. Translators: This is in the sense of locations for documents,
|
||||
#. network locations, etc.
|
||||
#: ../js/ui/dash.js:773
|
||||
#: ../js/ui/dash.js:653
|
||||
msgid "PLACES"
|
||||
msgstr "MÍSTA"
|
||||
|
||||
#. **** Documents ****
|
||||
#: ../js/ui/dash.js:780 ../js/ui/dash.js:819
|
||||
#: ../js/ui/dash.js:660 ../js/ui/dash.js:692
|
||||
msgid "RECENT DOCUMENTS"
|
||||
msgstr "NEDÁVNÉ DOKUMENTY"
|
||||
|
||||
#. **** Search Results ****
|
||||
#: ../js/ui/dash.js:799 ../js/ui/dash.js:931
|
||||
#: ../js/ui/dash.js:679
|
||||
msgid "SEARCH RESULTS"
|
||||
msgstr "VÝSLEDKY HLEDÁNÍ"
|
||||
|
||||
#: ../js/ui/dash.js:814
|
||||
msgid "PREFERENCES"
|
||||
msgstr "NASTAVENÍ"
|
||||
|
||||
#: ../js/ui/runDialog.js:101
|
||||
#: ../js/ui/runDialog.js:82
|
||||
msgid "Please enter a command:"
|
||||
msgstr "Zadejte prosím příkaz:"
|
||||
|
||||
#: ../src/shell-global.c:799
|
||||
#: ../src/shell-global.c:840
|
||||
msgid "Less than a minute ago"
|
||||
msgstr "Před méně než minutou"
|
||||
|
||||
#: ../src/shell-global.c:802
|
||||
#: ../src/shell-global.c:843
|
||||
#, c-format
|
||||
msgid "%d minute ago"
|
||||
msgid_plural "%d minutes ago"
|
||||
@ -88,7 +84,7 @@ msgstr[0] "Před %d minutou"
|
||||
msgstr[1] "Před %d minutami"
|
||||
msgstr[2] "Před %d minutami"
|
||||
|
||||
#: ../src/shell-global.c:805
|
||||
#: ../src/shell-global.c:846
|
||||
#, c-format
|
||||
msgid "%d hour ago"
|
||||
msgid_plural "%d hours ago"
|
||||
@ -96,7 +92,7 @@ msgstr[0] "Před %d hodinou"
|
||||
msgstr[1] "Před %d hodinami"
|
||||
msgstr[2] "Před %d hodinami"
|
||||
|
||||
#: ../src/shell-global.c:808
|
||||
#: ../src/shell-global.c:849
|
||||
#, c-format
|
||||
msgid "%d day ago"
|
||||
msgid_plural "%d days ago"
|
||||
@ -104,7 +100,7 @@ msgstr[0] "Před %d dnem"
|
||||
msgstr[1] "Před %d dny"
|
||||
msgstr[2] "Před %d dny"
|
||||
|
||||
#: ../src/shell-global.c:811
|
||||
#: ../src/shell-global.c:852
|
||||
#, c-format
|
||||
msgid "%d week ago"
|
||||
msgid_plural "%d weeks ago"
|
||||
|
25
po/es.po
25
po/es.po
@ -8,8 +8,8 @@ msgstr ""
|
||||
"Project-Id-Version: gnome-shell master\n"
|
||||
"Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?product=gnome-"
|
||||
"shell&component=general\n"
|
||||
"POT-Creation-Date: 2009-09-27 16:05+0000\n"
|
||||
"PO-Revision-Date: 2009-09-28 21:58+0200\n"
|
||||
"POT-Creation-Date: 2009-09-11 21:48+0000\n"
|
||||
"PO-Revision-Date: 2009-09-12 14:40+0200\n"
|
||||
"Last-Translator: Jorge González <jorgegonz@svn.gnome.org>\n"
|
||||
"Language-Team: Español <gnome-es-list@gnome.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -40,40 +40,40 @@ msgid "Find..."
|
||||
msgstr "Buscar…"
|
||||
|
||||
#: ../js/ui/dash.js:400
|
||||
msgid "More"
|
||||
msgstr "Más"
|
||||
msgid "Browse"
|
||||
msgstr "Examine"
|
||||
|
||||
#: ../js/ui/dash.js:543
|
||||
#: ../js/ui/dash.js:536
|
||||
msgid "(see all)"
|
||||
msgstr "(ver todo)"
|
||||
|
||||
#. **** Applications ****
|
||||
#: ../js/ui/dash.js:763 ../js/ui/dash.js:825
|
||||
#: ../js/ui/dash.js:736 ../js/ui/dash.js:792
|
||||
msgid "APPLICATIONS"
|
||||
msgstr "APLICACIONES"
|
||||
|
||||
#. **** Places ****
|
||||
#. Translators: This is in the sense of locations for documents,
|
||||
#. network locations, etc.
|
||||
#: ../js/ui/dash.js:783
|
||||
#: ../js/ui/dash.js:756
|
||||
msgid "PLACES"
|
||||
msgstr "LUGARES"
|
||||
|
||||
#. **** Documents ****
|
||||
#: ../js/ui/dash.js:790 ../js/ui/dash.js:835
|
||||
#: ../js/ui/dash.js:763 ../js/ui/dash.js:802
|
||||
msgid "RECENT DOCUMENTS"
|
||||
msgstr "DOCUMENTOS RECIENTES"
|
||||
|
||||
#. **** Search Results ****
|
||||
#: ../js/ui/dash.js:815 ../js/ui/dash.js:958
|
||||
#: ../js/ui/dash.js:782 ../js/ui/dash.js:907
|
||||
msgid "SEARCH RESULTS"
|
||||
msgstr "RESULTADOS DE LA BÚSQUEDA"
|
||||
|
||||
#: ../js/ui/dash.js:830
|
||||
#: ../js/ui/dash.js:797
|
||||
msgid "PREFERENCES"
|
||||
msgstr "PREFERENCIAS"
|
||||
|
||||
#: ../js/ui/runDialog.js:94
|
||||
#: ../js/ui/runDialog.js:90
|
||||
msgid "Please enter a command:"
|
||||
msgstr "Introduzca un comando:"
|
||||
|
||||
@ -185,9 +185,6 @@ msgstr "Buscar"
|
||||
msgid "%1$s: %2$s"
|
||||
msgstr "%1$s: %2$s"
|
||||
|
||||
#~ msgid "Browse"
|
||||
#~ msgstr "Examine"
|
||||
|
||||
#~ msgid "Find apps or documents"
|
||||
#~ msgstr "Encuentre aplicaciones o documentos"
|
||||
|
||||
|
83
po/hu.po
83
po/hu.po
@ -7,8 +7,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: gnome-shell master\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-09-28 13:41+0200\n"
|
||||
"PO-Revision-Date: 2009-09-28 13:42+0200\n"
|
||||
"POT-Creation-Date: 2009-08-15 11:35+0200\n"
|
||||
"PO-Revision-Date: 2009-08-15 11:35+0200\n"
|
||||
"Last-Translator: Gabor Kelemen <kelemeng at gnome dot hu>\n"
|
||||
"Language-Team: Hungarian <gnome at fsf dot hu>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -17,92 +17,77 @@ msgstr ""
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Generator: KBabel 1.11.4\n"
|
||||
|
||||
#: ../data/gnome-shell.desktop.in.in.h:1
|
||||
msgid "GNOME Shell"
|
||||
msgstr "GNOME Shell"
|
||||
|
||||
#: ../data/gnome-shell.desktop.in.in.h:2
|
||||
msgid "Window management and application launching"
|
||||
msgstr "Ablakkezelés és alkalmazásindítás"
|
||||
|
||||
#. left side
|
||||
#: ../js/ui/panel.js:269
|
||||
#: ../js/ui/panel.js:266
|
||||
msgid "Activities"
|
||||
msgstr "Tevékenységek"
|
||||
|
||||
#. Translators: This is a time format.
|
||||
#: ../js/ui/panel.js:452
|
||||
#: ../js/ui/panel.js:412
|
||||
msgid "%a %l:%M %p"
|
||||
msgstr "%a., %k.%M"
|
||||
|
||||
#: ../js/ui/dash.js:283
|
||||
msgid "Find..."
|
||||
msgstr "Keresés…"
|
||||
#: ../js/ui/dash.js:235
|
||||
msgid "Find apps or documents"
|
||||
msgstr "Alkalmazások vagy dokumentumok keresése"
|
||||
|
||||
#: ../js/ui/dash.js:400
|
||||
msgid "More"
|
||||
msgstr "Több"
|
||||
|
||||
#: ../js/ui/dash.js:543
|
||||
msgid "(see all)"
|
||||
msgstr "(összes megjelenítése)"
|
||||
#: ../js/ui/dash.js:336
|
||||
msgid "Browse"
|
||||
msgstr "Tallózás"
|
||||
|
||||
#. **** Applications ****
|
||||
#: ../js/ui/dash.js:763 ../js/ui/dash.js:825
|
||||
#: ../js/ui/dash.js:472 ../js/ui/dash.js:545
|
||||
msgid "APPLICATIONS"
|
||||
msgstr "ALKALMAZÁSOK"
|
||||
|
||||
#. **** Places ****
|
||||
#. Translators: This is in the sense of locations for documents,
|
||||
#. network locations, etc.
|
||||
#: ../js/ui/dash.js:783
|
||||
msgid "PLACES"
|
||||
msgstr "HELYEK"
|
||||
|
||||
#. **** Documents ****
|
||||
#: ../js/ui/dash.js:790 ../js/ui/dash.js:835
|
||||
#: ../js/ui/dash.js:477 ../js/ui/dash.js:570
|
||||
msgid "RECENT DOCUMENTS"
|
||||
msgstr "LEGUTÓBBI DOKUMENTUMOK"
|
||||
|
||||
#. **** Search Results ****
|
||||
#: ../js/ui/dash.js:815 ../js/ui/dash.js:958
|
||||
msgid "SEARCH RESULTS"
|
||||
msgstr "TALÁLATOK"
|
||||
#. **** Places ****
|
||||
#: ../js/ui/dash.js:563
|
||||
msgid "PLACES"
|
||||
msgstr "HELYEK"
|
||||
|
||||
#: ../js/ui/dash.js:830
|
||||
msgid "PREFERENCES"
|
||||
msgstr "BEÁLLÍTÁSOK"
|
||||
|
||||
#: ../js/ui/runDialog.js:94
|
||||
#: ../js/ui/runDialog.js:74
|
||||
msgid "Please enter a command:"
|
||||
msgstr "Adjon meg egy parancsot:"
|
||||
|
||||
#: ../src/shell-global.c:799
|
||||
#: ../src/gdmuser/gdm-user.c:242
|
||||
msgid "Manager"
|
||||
msgstr "Kezelő"
|
||||
|
||||
#: ../src/gdmuser/gdm-user.c:243
|
||||
msgid "The user manager object this user is controlled by."
|
||||
msgstr "A felhasználót kezelő felhasználókezelő objektum."
|
||||
|
||||
#: ../src/shell-global.c:841
|
||||
msgid "Less than a minute ago"
|
||||
msgstr "Kevesebb, mint egy perce"
|
||||
|
||||
#: ../src/shell-global.c:802
|
||||
#: ../src/shell-global.c:844
|
||||
#, c-format
|
||||
msgid "%d minute ago"
|
||||
msgid_plural "%d minutes ago"
|
||||
msgstr[0] "%d perce"
|
||||
msgstr[1] "%d perce"
|
||||
|
||||
#: ../src/shell-global.c:805
|
||||
#: ../src/shell-global.c:847
|
||||
#, c-format
|
||||
msgid "%d hour ago"
|
||||
msgid_plural "%d hours ago"
|
||||
msgstr[0] "%d órája"
|
||||
msgstr[1] "%d órája"
|
||||
|
||||
#: ../src/shell-global.c:808
|
||||
#: ../src/shell-global.c:850
|
||||
#, c-format
|
||||
msgid "%d day ago"
|
||||
msgid_plural "%d days ago"
|
||||
msgstr[0] "%d napja"
|
||||
msgstr[1] "%d napja"
|
||||
|
||||
#: ../src/shell-global.c:811
|
||||
#: ../src/shell-global.c:853
|
||||
#, c-format
|
||||
msgid "%d week ago"
|
||||
msgid_plural "%d weeks ago"
|
||||
@ -161,6 +146,14 @@ msgstr "Kijelentkezés…"
|
||||
msgid "Shut Down..."
|
||||
msgstr "Leállítás…"
|
||||
|
||||
#: ../data/gnome-shell.desktop.in.in.h:1
|
||||
msgid "GNOME Shell"
|
||||
msgstr "GNOME Shell"
|
||||
|
||||
#: ../data/gnome-shell.desktop.in.in.h:2
|
||||
msgid "Window management and application launching"
|
||||
msgstr "Ablakkezelés és alkalmazásindítás"
|
||||
|
||||
#: ../src/shell-uri-util.c:87
|
||||
msgid "Home Folder"
|
||||
msgstr "Saját mappa"
|
||||
|
107
po/pt_BR.po
107
po/pt_BR.po
@ -2,107 +2,91 @@
|
||||
# Copyright (C) 2009 THE gnome-shell'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the gnome-shell package.
|
||||
# Og Maciel <ogmaciel@gnome.org>, 2009.
|
||||
# Rodrigo Flores <mail@rodrigoflores.org>, 2009.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-09-21 08:39-0300\n"
|
||||
"PO-Revision-Date: 2009-09-20 08:41-0300\n"
|
||||
"Last-Translator: Rodrigo Flores <mail@rodrigoflores.org>\n"
|
||||
"POT-Creation-Date: 2009-08-14 17:53-0400\n"
|
||||
"PO-Revision-Date: 2009-08-14 17:53-0400\n"
|
||||
"Last-Translator: Og Maciel <ogmaciel@gnome.org>\n"
|
||||
"Language-Team: Brazilian Portuguese <gnome-pt_br-list@gnome.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#: ../data/gnome-shell.desktop.in.in.h:1
|
||||
msgid "GNOME Shell"
|
||||
msgstr "GNOME Shell"
|
||||
|
||||
#: ../data/gnome-shell.desktop.in.in.h:2
|
||||
msgid "Window management and application launching"
|
||||
msgstr "Gerenciamento de janelas e lançador de aplicações"
|
||||
|
||||
#. left side
|
||||
#: ../js/ui/panel.js:269
|
||||
#: ../js/ui/panel.js:266
|
||||
msgid "Activities"
|
||||
msgstr "Atividades"
|
||||
|
||||
#. Translators: This is a time format.
|
||||
#: ../js/ui/panel.js:452
|
||||
#: ../js/ui/panel.js:412
|
||||
msgid "%a %l:%M %p"
|
||||
msgstr "%a %l:%M %p"
|
||||
|
||||
#: ../js/ui/dash.js:283
|
||||
msgid "Find..."
|
||||
msgstr "Encontre..."
|
||||
#: ../js/ui/dash.js:235
|
||||
msgid "Find apps or documents"
|
||||
msgstr "Localizar aplicativos ou documentos"
|
||||
|
||||
#: ../js/ui/dash.js:400
|
||||
#: ../js/ui/dash.js:336
|
||||
msgid "Browse"
|
||||
msgstr "Navegar"
|
||||
|
||||
#: ../js/ui/dash.js:536
|
||||
msgid "(see all)"
|
||||
msgstr "(veja todos)"
|
||||
|
||||
#. **** Applications ****
|
||||
#: ../js/ui/dash.js:753 ../js/ui/dash.js:809
|
||||
#: ../js/ui/dash.js:472 ../js/ui/dash.js:545
|
||||
msgid "APPLICATIONS"
|
||||
msgstr "APLICATIVOS"
|
||||
|
||||
#. **** Places ****
|
||||
#. Translators: This is in the sense of locations for documents,
|
||||
#. network locations, etc.
|
||||
#: ../js/ui/dash.js:773
|
||||
msgid "PLACES"
|
||||
msgstr "LOCAIS"
|
||||
|
||||
#. **** Documents ****
|
||||
#: ../js/ui/dash.js:780 ../js/ui/dash.js:819
|
||||
#: ../js/ui/dash.js:477 ../js/ui/dash.js:570
|
||||
msgid "RECENT DOCUMENTS"
|
||||
msgstr "DOCUMENTOS RECENTES"
|
||||
|
||||
#. **** Search Results ****
|
||||
#: ../js/ui/dash.js:799 ../js/ui/dash.js:931
|
||||
msgid "SEARCH RESULTS"
|
||||
msgstr "RESULTADOS DA BUSCA"
|
||||
#. **** Places ****
|
||||
#: ../js/ui/dash.js:563
|
||||
msgid "PLACES"
|
||||
msgstr "LOCAIS"
|
||||
|
||||
#: ../js/ui/dash.js:814
|
||||
msgid "PREFERENCES"
|
||||
msgstr "PREFERÊNCIAS"
|
||||
|
||||
#: ../js/ui/runDialog.js:101
|
||||
#: ../js/ui/runDialog.js:74
|
||||
msgid "Please enter a command:"
|
||||
msgstr "Por favor digite um comando:"
|
||||
|
||||
#: ../src/shell-global.c:799
|
||||
#: ../src/gdmuser/gdm-user.c:242
|
||||
msgid "Manager"
|
||||
msgstr "Gerenciador"
|
||||
|
||||
#: ../src/gdmuser/gdm-user.c:243
|
||||
msgid "The user manager object this user is controlled by."
|
||||
msgstr "O objeto gerenciador de usuários que controla este usuário."
|
||||
|
||||
#: ../src/shell-global.c:841
|
||||
msgid "Less than a minute ago"
|
||||
msgstr "Menos de um minuto atrás"
|
||||
|
||||
#: ../src/shell-global.c:802
|
||||
#: ../src/shell-global.c:844
|
||||
#, c-format
|
||||
msgid "%d minute ago"
|
||||
msgid_plural "%d minutes ago"
|
||||
msgstr[0] "%d minuto atrás"
|
||||
msgstr[1] "%d minutos atrás"
|
||||
|
||||
#: ../src/shell-global.c:805
|
||||
#: ../src/shell-global.c:847
|
||||
#, c-format
|
||||
msgid "%d hour ago"
|
||||
msgid_plural "%d hours ago"
|
||||
msgstr[0] "%d hora atrás"
|
||||
msgstr[1] "%d horas atrás"
|
||||
|
||||
#: ../src/shell-global.c:808
|
||||
#: ../src/shell-global.c:850
|
||||
#, c-format
|
||||
msgid "%d day ago"
|
||||
msgid_plural "%d days ago"
|
||||
msgstr[0] "%d dia atrás"
|
||||
msgstr[1] "%d dias atrás"
|
||||
|
||||
#: ../src/shell-global.c:811
|
||||
#: ../src/shell-global.c:853
|
||||
#, c-format
|
||||
msgid "%d week ago"
|
||||
msgid_plural "%d weeks ago"
|
||||
@ -158,36 +142,3 @@ msgstr "Encerrar sessão..."
|
||||
#: ../src/shell-status-menu.c:557
|
||||
msgid "Shut Down..."
|
||||
msgstr "Desligar..."
|
||||
|
||||
#: ../src/shell-uri-util.c:87
|
||||
msgid "Home Folder"
|
||||
msgstr "Pasta home"
|
||||
|
||||
#. Translators: this is the same string as the one found in
|
||||
#. * nautilus
|
||||
#: ../src/shell-uri-util.c:102
|
||||
msgid "File System"
|
||||
msgstr "Sistema de arquivos"
|
||||
|
||||
#: ../src/shell-uri-util.c:248
|
||||
msgid "Search"
|
||||
msgstr "Procurar"
|
||||
|
||||
#. Translators: the first string is the name of a gvfs
|
||||
#. * method, and the second string is a path. For
|
||||
#. * example, "Trash: some-directory". It means that the
|
||||
#. * directory called "some-directory" is in the trash.
|
||||
#.
|
||||
#: ../src/shell-uri-util.c:298
|
||||
#, c-format
|
||||
msgid "%1$s: %2$s"
|
||||
msgstr "%1$s: %2$s"
|
||||
|
||||
#~ msgid "Find apps or documents"
|
||||
#~ msgstr "Localizar aplicativos ou documentos"
|
||||
|
||||
#~ msgid "Manager"
|
||||
#~ msgstr "Gerenciador"
|
||||
|
||||
#~ msgid "The user manager object this user is controlled by."
|
||||
#~ msgstr "O objeto gerenciador de usuários que controla este usuário."
|
||||
|
198
po/sl.po
198
po/sl.po
@ -1,198 +0,0 @@
|
||||
# Slovenian translation for gnome-shell.
|
||||
# This file is distributed under the same license as the gnome-shell package.
|
||||
# Matej Urbančič <mateju@svn.gnome.org>, 2009.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: gnome-shell master\n"
|
||||
"Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?product=gnome-shell&component=general\n"
|
||||
"POT-Creation-Date: 2009-09-21 22:38+0000\n"
|
||||
"PO-Revision-Date: 2009-09-22 10:36+0100\n"
|
||||
"Last-Translator: Matej Urbančič <mateju@svn.gnome.org>\n"
|
||||
"Language-Team: Slovenian <gnome-si@googlegroups.com>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Language: Slovenian\n"
|
||||
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 1 : n%100==2 ? 2 : n%100==3 || n%100==4 ? 3 : 0);\n"
|
||||
"X-Poedit-Language: Slovenian\n"
|
||||
"X-Poedit-Country: SLOVENIA\n"
|
||||
"X-Poedit-SourceCharset: utf-8\n"
|
||||
|
||||
#: ../data/gnome-shell.desktop.in.in.h:1
|
||||
msgid "GNOME Shell"
|
||||
msgstr "Gnome lupina"
|
||||
|
||||
#: ../data/gnome-shell.desktop.in.in.h:2
|
||||
msgid "Window management and application launching"
|
||||
msgstr "Upravljanje oken in zaganjanje programov"
|
||||
|
||||
#. left side
|
||||
#: ../js/ui/panel.js:269
|
||||
msgid "Activities"
|
||||
msgstr "Dejavnosti"
|
||||
|
||||
#. Translators: This is a time format.
|
||||
#: ../js/ui/panel.js:452
|
||||
msgid "%a %l:%M %p"
|
||||
msgstr "%a, %H:%M"
|
||||
|
||||
#: ../js/ui/dash.js:283
|
||||
msgid "Find..."
|
||||
msgstr "Poišči ..."
|
||||
|
||||
#: ../js/ui/dash.js:400
|
||||
msgid "Browse"
|
||||
msgstr "Prebrskaj"
|
||||
|
||||
#: ../js/ui/dash.js:536
|
||||
msgid "(see all)"
|
||||
msgstr "(poglej vse)"
|
||||
|
||||
#. **** Applications ****
|
||||
#: ../js/ui/dash.js:753
|
||||
#: ../js/ui/dash.js:809
|
||||
msgid "APPLICATIONS"
|
||||
msgstr "Programi"
|
||||
|
||||
#. **** Places ****
|
||||
#. Translators: This is in the sense of locations for documents,
|
||||
#. network locations, etc.
|
||||
#: ../js/ui/dash.js:773
|
||||
msgid "PLACES"
|
||||
msgstr "Mesta"
|
||||
|
||||
#. **** Documents ****
|
||||
#: ../js/ui/dash.js:780
|
||||
#: ../js/ui/dash.js:819
|
||||
msgid "RECENT DOCUMENTS"
|
||||
msgstr "Nedavni dokumenti"
|
||||
|
||||
#. **** Search Results ****
|
||||
#: ../js/ui/dash.js:799
|
||||
#: ../js/ui/dash.js:931
|
||||
msgid "SEARCH RESULTS"
|
||||
msgstr "Rezultati iskanja"
|
||||
|
||||
#: ../js/ui/dash.js:814
|
||||
msgid "PREFERENCES"
|
||||
msgstr "Lastnosti"
|
||||
|
||||
#: ../js/ui/runDialog.js:101
|
||||
msgid "Please enter a command:"
|
||||
msgstr "Prosim, vnesite ukaz:"
|
||||
|
||||
#: ../src/shell-global.c:799
|
||||
msgid "Less than a minute ago"
|
||||
msgstr "Pred manj kot eno minuto"
|
||||
|
||||
#: ../src/shell-global.c:802
|
||||
#, c-format
|
||||
msgid "%d minute ago"
|
||||
msgid_plural "%d minutes ago"
|
||||
msgstr[0] "Pred %d minutami"
|
||||
msgstr[1] "Pred %d minuto"
|
||||
msgstr[2] "Pred %d minutama"
|
||||
msgstr[3] "Pred %d minutami"
|
||||
|
||||
#: ../src/shell-global.c:805
|
||||
#, c-format
|
||||
msgid "%d hour ago"
|
||||
msgid_plural "%d hours ago"
|
||||
msgstr[0] "Pred %d urami"
|
||||
msgstr[1] "Pred %d uro"
|
||||
msgstr[2] "Pred %d urama"
|
||||
msgstr[3] "Pred %d urami"
|
||||
|
||||
#: ../src/shell-global.c:808
|
||||
#, c-format
|
||||
msgid "%d day ago"
|
||||
msgid_plural "%d days ago"
|
||||
msgstr[0] "Pred %d dnevi"
|
||||
msgstr[1] "Pred %d dnevom"
|
||||
msgstr[2] "Pred %d dnevoma"
|
||||
msgstr[3] "Pred %d dnevi"
|
||||
|
||||
#: ../src/shell-global.c:811
|
||||
#, c-format
|
||||
msgid "%d week ago"
|
||||
msgid_plural "%d weeks ago"
|
||||
msgstr[0] "Pred %d tedni"
|
||||
msgstr[1] "Pred %d tednom"
|
||||
msgstr[2] "Pred %d tednoma"
|
||||
msgstr[3] "Pred %d tedni"
|
||||
|
||||
#: ../src/shell-status-menu.c:156
|
||||
msgid "Unknown"
|
||||
msgstr "Neznano"
|
||||
|
||||
#: ../src/shell-status-menu.c:212
|
||||
#, c-format
|
||||
msgid "Can't lock screen: %s"
|
||||
msgstr "Ni mogoče zakleniti zaslona: %s"
|
||||
|
||||
#: ../src/shell-status-menu.c:227
|
||||
#, c-format
|
||||
msgid "Can't temporarily set screensaver to blank screen: %s"
|
||||
msgstr "Ni mogoče začasno nastaviti črnega zaslona za ohranjevalnik zaslona: %s"
|
||||
|
||||
#: ../src/shell-status-menu.c:351
|
||||
#, c-format
|
||||
msgid "Can't logout: %s"
|
||||
msgstr "Ni se mogoče odjaviti: %s"
|
||||
|
||||
#: ../src/shell-status-menu.c:492
|
||||
msgid "Account Information..."
|
||||
msgstr "Podrobnosti računa ..."
|
||||
|
||||
#: ../src/shell-status-menu.c:502
|
||||
msgid "Sidebar"
|
||||
msgstr "_Stranska vrstica"
|
||||
|
||||
#: ../src/shell-status-menu.c:510
|
||||
msgid "System Preferences..."
|
||||
msgstr "Sistemske lastnosti ..."
|
||||
|
||||
#: ../src/shell-status-menu.c:525
|
||||
msgid "Lock Screen"
|
||||
msgstr "Zakleni zaslon"
|
||||
|
||||
#: ../src/shell-status-menu.c:535
|
||||
msgid "Switch User"
|
||||
msgstr "Preklop uporabnika"
|
||||
|
||||
#. Only show switch user if there are other users
|
||||
#. Log Out
|
||||
#: ../src/shell-status-menu.c:546
|
||||
msgid "Log Out..."
|
||||
msgstr "Odjava ..."
|
||||
|
||||
#. Shut down
|
||||
#: ../src/shell-status-menu.c:557
|
||||
msgid "Shut Down..."
|
||||
msgstr "Izklop ..."
|
||||
|
||||
#: ../src/shell-uri-util.c:87
|
||||
msgid "Home Folder"
|
||||
msgstr "Domača mapa"
|
||||
|
||||
#. Translators: this is the same string as the one found in
|
||||
#. * nautilus
|
||||
#: ../src/shell-uri-util.c:102
|
||||
msgid "File System"
|
||||
msgstr "Datotečni sistem"
|
||||
|
||||
#: ../src/shell-uri-util.c:248
|
||||
msgid "Search"
|
||||
msgstr "Iskanje"
|
||||
|
||||
#. Translators: the first string is the name of a gvfs
|
||||
#. * method, and the second string is a path. For
|
||||
#. * example, "Trash: some-directory". It means that the
|
||||
#. * directory called "some-directory" is in the trash.
|
||||
#.
|
||||
#: ../src/shell-uri-util.c:298
|
||||
#, c-format
|
||||
msgid "%1$s: %2$s"
|
||||
msgstr "%1$s: %2$s"
|
||||
|
43
po/sv.po
43
po/sv.po
@ -7,8 +7,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: gnome-shell\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-09-18 13:02+0200\n"
|
||||
"PO-Revision-Date: 2009-09-18 13:02+0100\n"
|
||||
"POT-Creation-Date: 2009-09-01 00:31+0200\n"
|
||||
"PO-Revision-Date: 2009-09-01 00:31+0100\n"
|
||||
"Last-Translator: Daniel Nylander <po@danielnylander.se>\n"
|
||||
"Language-Team: Swedish <tp-sv@listor.tp-sv.se>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -25,86 +25,81 @@ msgid "Window management and application launching"
|
||||
msgstr "Fönsterhantering och programstarter"
|
||||
|
||||
#. left side
|
||||
#: ../js/ui/panel.js:269
|
||||
#: ../js/ui/panel.js:271
|
||||
msgid "Activities"
|
||||
msgstr "Aktiviteter"
|
||||
|
||||
#. Translators: This is a time format.
|
||||
#: ../js/ui/panel.js:452
|
||||
#: ../js/ui/panel.js:454
|
||||
msgid "%a %l:%M %p"
|
||||
msgstr "%a %H.%M"
|
||||
|
||||
#: ../js/ui/dash.js:283
|
||||
#: ../js/ui/dash.js:256
|
||||
msgid "Find..."
|
||||
msgstr "Sök..."
|
||||
|
||||
#: ../js/ui/dash.js:400
|
||||
#: ../js/ui/dash.js:374
|
||||
msgid "Browse"
|
||||
msgstr "Bläddra"
|
||||
|
||||
#: ../js/ui/dash.js:536
|
||||
#: ../js/ui/dash.js:451
|
||||
msgid "(see all)"
|
||||
msgstr "(se alla)"
|
||||
|
||||
#. **** Applications ****
|
||||
#: ../js/ui/dash.js:753
|
||||
#: ../js/ui/dash.js:809
|
||||
#: ../js/ui/dash.js:633
|
||||
#: ../js/ui/dash.js:681
|
||||
msgid "APPLICATIONS"
|
||||
msgstr "PROGRAM"
|
||||
|
||||
#. **** Places ****
|
||||
#. Translators: This is in the sense of locations for documents,
|
||||
#. network locations, etc.
|
||||
#: ../js/ui/dash.js:773
|
||||
#: ../js/ui/dash.js:653
|
||||
msgid "PLACES"
|
||||
msgstr "PLATSER"
|
||||
|
||||
#. **** Documents ****
|
||||
#: ../js/ui/dash.js:780
|
||||
#: ../js/ui/dash.js:819
|
||||
#: ../js/ui/dash.js:660
|
||||
#: ../js/ui/dash.js:692
|
||||
msgid "RECENT DOCUMENTS"
|
||||
msgstr "SENASTE DOKUMENT"
|
||||
|
||||
#. **** Search Results ****
|
||||
#: ../js/ui/dash.js:799
|
||||
#: ../js/ui/dash.js:931
|
||||
#: ../js/ui/dash.js:679
|
||||
msgid "SEARCH RESULTS"
|
||||
msgstr "SÖKRESULTAT"
|
||||
|
||||
#: ../js/ui/dash.js:814
|
||||
msgid "PREFERENCES"
|
||||
msgstr "INSTÄLLNINGAR"
|
||||
|
||||
#: ../js/ui/runDialog.js:101
|
||||
#: ../js/ui/runDialog.js:82
|
||||
msgid "Please enter a command:"
|
||||
msgstr "Ange ett kommando:"
|
||||
|
||||
#: ../src/shell-global.c:799
|
||||
#: ../src/shell-global.c:840
|
||||
msgid "Less than a minute ago"
|
||||
msgstr "Mindre än en minut sedan"
|
||||
|
||||
#: ../src/shell-global.c:802
|
||||
#: ../src/shell-global.c:843
|
||||
#, c-format
|
||||
msgid "%d minute ago"
|
||||
msgid_plural "%d minutes ago"
|
||||
msgstr[0] "%d minut sedan"
|
||||
msgstr[1] "%d minuter sedan"
|
||||
|
||||
#: ../src/shell-global.c:805
|
||||
#: ../src/shell-global.c:846
|
||||
#, c-format
|
||||
msgid "%d hour ago"
|
||||
msgid_plural "%d hours ago"
|
||||
msgstr[0] "%d timme sedan"
|
||||
msgstr[1] "%d timmar sedan"
|
||||
|
||||
#: ../src/shell-global.c:808
|
||||
#: ../src/shell-global.c:849
|
||||
#, c-format
|
||||
msgid "%d day ago"
|
||||
msgid_plural "%d days ago"
|
||||
msgstr[0] "%d dag sedan"
|
||||
msgstr[1] "%d dagar sedan"
|
||||
|
||||
#: ../src/shell-global.c:811
|
||||
#: ../src/shell-global.c:852
|
||||
#, c-format
|
||||
msgid "%d week ago"
|
||||
msgid_plural "%d weeks ago"
|
||||
|
117
src/Makefile-nbtk.am
Normal file
117
src/Makefile-nbtk.am
Normal file
@ -0,0 +1,117 @@
|
||||
nbtk_cflags = \
|
||||
-I$(top_srcdir)/src \
|
||||
-DPREFIX=\""$(prefix)"\" \
|
||||
-DLIBDIR=\""$(libdir)"\" \
|
||||
-DG_DISABLE_DEPRECATED \
|
||||
-DG_LOG_DOMAIN=\"Nbtk\" \
|
||||
-DNBTK_COMPILATION \
|
||||
$(NBTK_CFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
nbtk_built_sources = \
|
||||
nbtk-enum-types.h \
|
||||
nbtk-enum-types.c \
|
||||
nbtk-marshal.h \
|
||||
nbtk-marshal.c
|
||||
|
||||
BUILT_SOURCES += $(nbtk_built_sources)
|
||||
|
||||
EXTRA_DIST += \
|
||||
nbtk/nbtk-marshal.list \
|
||||
nbtk/nbtk-enum-types.h.in \
|
||||
nbtk/nbtk-enum-types.c.in
|
||||
|
||||
CLEANFILES += stamp-nbtk-marshal.h stamp-nbtk-enum-types.h
|
||||
|
||||
nbtk-marshal.h: stamp-nbtk-marshal.h
|
||||
@true
|
||||
stamp-nbtk-marshal.h: Makefile nbtk/nbtk-marshal.list
|
||||
$(AM_V_GEN) $(GLIB_GENMARSHAL) \
|
||||
--prefix=_nbtk_marshal \
|
||||
--header \
|
||||
$(srcdir)/nbtk/nbtk-marshal.list > $@.tmp && \
|
||||
(cmp -s $@.tmp nbtk-marshal.h || cp -f $@.tmp nbtk-marshal.h) && \
|
||||
rm -f $@.tmp && \
|
||||
echo timestamp > $(@F)
|
||||
|
||||
nbtk-marshal.c: Makefile nbtk/nbtk-marshal.list
|
||||
$(AM_V_GEN) (echo "#include \"nbtk-marshal.h\"" ; \
|
||||
$(GLIB_GENMARSHAL) \
|
||||
--prefix=_nbtk_marshal \
|
||||
--body \
|
||||
$(srcdir)/nbtk/nbtk-marshal.list ) > $@.tmp && \
|
||||
cp -f $@.tmp nbtk-marshal.c && \
|
||||
rm -f $@.tmp
|
||||
|
||||
nbtk-enum-types.h: stamp-nbtk-enum-types.h Makefile
|
||||
@true
|
||||
stamp-nbtk-enum-types.h: $(source_h) nbtk/nbtk-enum-types.h.in
|
||||
$(AM_V_GEN) ( cd $(srcdir) && \
|
||||
$(GLIB_MKENUMS) \
|
||||
--template nbtk/nbtk-enum-types.h.in \
|
||||
$(nbtk_source_h) ) >> $@.tmp && \
|
||||
(cmp -s $@.tmp nbtk-enum-types.h || cp $@.tmp nbtk-enum-types.h) && \
|
||||
rm -f $@.tmp && \
|
||||
echo timestamp > $(@F)
|
||||
|
||||
nbtk-enum-types.c: stamp-nbtk-enum-types.h nbtk/nbtk-enum-types.c.in
|
||||
$(AM_V_GEN) ( cd $(srcdir) && \
|
||||
$(GLIB_MKENUMS) \
|
||||
--template nbtk/nbtk-enum-types.c.in \
|
||||
$(nbtk_source_h) ) >> $@.tmp && \
|
||||
cp $@.tmp $@ && \
|
||||
rm -f $@.tmp
|
||||
|
||||
# please, keep this sorted alphabetically
|
||||
nbtk_source_h = \
|
||||
nbtk/nbtk-adjustment.h \
|
||||
nbtk/nbtk-bin.h \
|
||||
nbtk/nbtk-box-layout.h \
|
||||
nbtk/nbtk-box-layout-child.h \
|
||||
nbtk/nbtk-button.h \
|
||||
nbtk/nbtk-clipboard.h \
|
||||
nbtk/nbtk-entry.h \
|
||||
nbtk/nbtk-label.h \
|
||||
nbtk/nbtk-private.h \
|
||||
nbtk/nbtk-scrollable.h \
|
||||
nbtk/nbtk-scroll-bar.h \
|
||||
nbtk/nbtk-scroll-view.h \
|
||||
nbtk/nbtk-subtexture.h \
|
||||
nbtk/nbtk-texture-cache.h \
|
||||
nbtk/nbtk-texture-frame.h \
|
||||
nbtk/nbtk-tooltip.h \
|
||||
nbtk/nbtk-types.h \
|
||||
nbtk/nbtk-widget.h \
|
||||
$(NULL)
|
||||
|
||||
# please, keep this sorted alphabetically
|
||||
nbtk_source_c = \
|
||||
nbtk/nbtk-adjustment.c \
|
||||
nbtk/nbtk-bin.c \
|
||||
nbtk/nbtk-box-layout.c \
|
||||
nbtk/nbtk-box-layout-child.c \
|
||||
nbtk/nbtk-button.c \
|
||||
nbtk/nbtk-clipboard.c \
|
||||
nbtk/nbtk-entry.c \
|
||||
nbtk/nbtk-label.c \
|
||||
nbtk/nbtk-private.c \
|
||||
nbtk/nbtk-scrollable.c \
|
||||
nbtk/nbtk-scroll-bar.c \
|
||||
nbtk/nbtk-scroll-view.c \
|
||||
nbtk/nbtk-subtexture.c \
|
||||
nbtk/nbtk-texture-cache.c \
|
||||
nbtk/nbtk-texture-frame.c \
|
||||
nbtk/nbtk-tooltip.c \
|
||||
nbtk/nbtk-widget.c \
|
||||
$(NULL)
|
||||
|
||||
noinst_LTLIBRARIES += libnbtk-1.0.la
|
||||
|
||||
libnbtk_1_0_la_LIBADD = $(NBTK_LIBS)
|
||||
libnbtk_1_0_la_SOURCES = \
|
||||
$(nbtk_source_c) \
|
||||
$(nbtk_source_h) \
|
||||
$(nbtk_built_sources) \
|
||||
$(NULL)
|
||||
libnbtk_1_0_la_CPPFLAGS = $(nbtk_cflags)
|
||||
libnbtk_1_0_la_LDFLAGS = $(LDADD)
|
@ -1,142 +0,0 @@
|
||||
st_cflags = \
|
||||
-I$(top_srcdir)/src \
|
||||
-DPREFIX=\""$(prefix)"\" \
|
||||
-DLIBDIR=\""$(libdir)"\" \
|
||||
-DG_DISABLE_DEPRECATED \
|
||||
-DG_LOG_DOMAIN=\"St\" \
|
||||
-DST_COMPILATION \
|
||||
-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" \
|
||||
$(ST_CFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
st_built_sources = \
|
||||
st-enum-types.h \
|
||||
st-enum-types.c \
|
||||
st-marshal.h \
|
||||
st-marshal.c
|
||||
|
||||
BUILT_SOURCES += $(st_built_sources)
|
||||
|
||||
EXTRA_DIST += \
|
||||
st/st-marshal.list \
|
||||
st/st-enum-types.h.in \
|
||||
st/st-enum-types.c.in
|
||||
|
||||
CLEANFILES += stamp-st-marshal.h stamp-st-enum-types.h
|
||||
|
||||
st-marshal.h: stamp-st-marshal.h
|
||||
@true
|
||||
stamp-st-marshal.h: Makefile st/st-marshal.list
|
||||
$(AM_V_GEN) $(GLIB_GENMARSHAL) \
|
||||
--prefix=_st_marshal \
|
||||
--header \
|
||||
$(srcdir)/st/st-marshal.list > $@.tmp && \
|
||||
(cmp -s $@.tmp st-marshal.h || cp -f $@.tmp st-marshal.h) && \
|
||||
rm -f $@.tmp && \
|
||||
echo timestamp > $(@F)
|
||||
|
||||
st-marshal.c: Makefile st/st-marshal.list
|
||||
$(AM_V_GEN) (echo "#include \"st-marshal.h\"" ; \
|
||||
$(GLIB_GENMARSHAL) \
|
||||
--prefix=_st_marshal \
|
||||
--body \
|
||||
$(srcdir)/st/st-marshal.list ) > $@.tmp && \
|
||||
cp -f $@.tmp st-marshal.c && \
|
||||
rm -f $@.tmp
|
||||
|
||||
st-enum-types.h: stamp-st-enum-types.h Makefile
|
||||
@true
|
||||
stamp-st-enum-types.h: $(source_h) st/st-enum-types.h.in
|
||||
$(AM_V_GEN) ( cd $(srcdir) && \
|
||||
$(GLIB_MKENUMS) \
|
||||
--template st/st-enum-types.h.in \
|
||||
$(st_source_h) ) >> $@.tmp && \
|
||||
(cmp -s $@.tmp st-enum-types.h || cp $@.tmp st-enum-types.h) && \
|
||||
rm -f $@.tmp && \
|
||||
echo timestamp > $(@F)
|
||||
|
||||
st-enum-types.c: stamp-st-enum-types.h st/st-enum-types.c.in
|
||||
$(AM_V_GEN) ( cd $(srcdir) && \
|
||||
$(GLIB_MKENUMS) \
|
||||
--template st/st-enum-types.c.in \
|
||||
$(st_source_h) ) >> $@.tmp && \
|
||||
cp $@.tmp $@ && \
|
||||
rm -f $@.tmp
|
||||
|
||||
# please, keep this sorted alphabetically
|
||||
st_source_h = \
|
||||
st/st-adjustment.h \
|
||||
st/st-bin.h \
|
||||
st/st-border-image.h \
|
||||
st/st-box-layout.h \
|
||||
st/st-box-layout-child.h \
|
||||
st/st-button.h \
|
||||
st/st-clipboard.h \
|
||||
st/st-entry.h \
|
||||
st/st-label.h \
|
||||
st/st-scrollable.h \
|
||||
st/st-scroll-bar.h \
|
||||
st/st-scroll-view.h \
|
||||
st/st-subtexture.h \
|
||||
st/st-table.h \
|
||||
st/st-table-child.h \
|
||||
st/st-texture-cache.h \
|
||||
st/st-texture-frame.h \
|
||||
st/st-theme.h \
|
||||
st/st-theme-context.h \
|
||||
st/st-theme-node.h \
|
||||
st/st-tooltip.h \
|
||||
st/st-types.h \
|
||||
st/st-widget.h \
|
||||
$(NULL)
|
||||
|
||||
st_source_private_h = \
|
||||
st/st-private.h \
|
||||
st/st-table-private.h \
|
||||
st/st-theme-private.h
|
||||
|
||||
# please, keep this sorted alphabetically
|
||||
st_source_c = \
|
||||
st/st-adjustment.c \
|
||||
st/st-bin.c \
|
||||
st/st-border-image.c \
|
||||
st/st-box-layout.c \
|
||||
st/st-box-layout-child.c \
|
||||
st/st-button.c \
|
||||
st/st-clipboard.c \
|
||||
st/st-entry.c \
|
||||
st/st-label.c \
|
||||
st/st-private.c \
|
||||
st/st-scrollable.c \
|
||||
st/st-scroll-bar.c \
|
||||
st/st-scroll-view.c \
|
||||
st/st-subtexture.c \
|
||||
st/st-table.c \
|
||||
st/st-table-child.c \
|
||||
st/st-texture-cache.c \
|
||||
st/st-texture-frame.c \
|
||||
st/st-theme.c \
|
||||
st/st-theme-context.c \
|
||||
st/st-theme-node.c \
|
||||
st/st-tooltip.c \
|
||||
st/st-widget.c \
|
||||
$(NULL)
|
||||
|
||||
noinst_LTLIBRARIES += libst-1.0.la
|
||||
|
||||
libst_1_0_la_LIBADD = $(ST_LIBS)
|
||||
libst_1_0_la_SOURCES = \
|
||||
$(st_source_c) \
|
||||
$(st_source_private_c) \
|
||||
$(st_source_h) \
|
||||
$(st_built_sources) \
|
||||
$(NULL)
|
||||
libst_1_0_la_CPPFLAGS = $(st_cflags)
|
||||
libst_1_0_la_LDFLAGS = $(LDADD)
|
||||
|
||||
noinst_PROGRAMS += test-theme
|
||||
|
||||
test_theme_CPPFLAGS = $(st_cflags)
|
||||
test_theme_LDADD = libst-1.0.la
|
||||
|
||||
test_theme_SOURCES = st/test-theme.c
|
36
src/Makefile-toolkit.am
Normal file
36
src/Makefile-toolkit.am
Normal file
@ -0,0 +1,36 @@
|
||||
toolkit_cflags = \
|
||||
-I$(top_srcdir)/src \
|
||||
-DPREFIX=\""$(prefix)"\" \
|
||||
-DLIBDIR=\""$(libdir)"\" \
|
||||
-DG_DISABLE_DEPRECATED \
|
||||
-DG_LOG_DOMAIN=\"Shell\" \
|
||||
$(TOOLKIT_CFLAGS)
|
||||
|
||||
# please, keep this sorted alphabetically
|
||||
toolkit_sources = \
|
||||
toolkit/shell-border-image.c \
|
||||
toolkit/shell-border-image.h \
|
||||
toolkit/shell-theme.c \
|
||||
toolkit/shell-theme.h \
|
||||
toolkit/shell-theme-context.c \
|
||||
toolkit/shell-theme-context.h \
|
||||
toolkit/shell-theme-node.c \
|
||||
toolkit/shell-theme-node.h \
|
||||
toolkit/shell-theme-private.h
|
||||
|
||||
non_gir_toolkit_sources = \
|
||||
toolkit/shell-theme-private.h
|
||||
|
||||
noinst_LTLIBRARIES += libshell-toolkit.la
|
||||
|
||||
libshell_toolkit_la_LIBADD = $(TOOLKIT_LIBS)
|
||||
libshell_toolkit_la_SOURCES = $(toolkit_sources) $(toolkit_built_sources)
|
||||
libshell_toolkit_la_CPPFLAGS = $(toolkit_cflags)
|
||||
libshell_toolkit_la_LDFLAGS = $(LDADD)
|
||||
|
||||
noinst_PROGRAMS += test-theme
|
||||
|
||||
test_theme_CPPFLAGS = $(toolkit_cflags)
|
||||
test_theme_LDADD = libshell-toolkit.la
|
||||
|
||||
test_theme_SOURCES = toolkit/test-theme.c
|
@ -25,7 +25,8 @@ EXTRA_DIST += gnome-shell.in
|
||||
|
||||
include Makefile-big.am
|
||||
include Makefile-gdmuser.am
|
||||
include Makefile-st.am
|
||||
include Makefile-nbtk.am
|
||||
include Makefile-toolkit.am
|
||||
include Makefile-tray.am
|
||||
|
||||
gnome_shell_cflags = \
|
||||
@ -54,6 +55,8 @@ CLEANFILES += $(SHELL_STAMP_FILES)
|
||||
libgnome_shell_la_SOURCES = \
|
||||
$(shell_built_sources) \
|
||||
gnome-shell-plugin.c \
|
||||
shell-alttab.c \
|
||||
shell-alttab.h \
|
||||
shell-app-monitor.c \
|
||||
shell-app-monitor.h \
|
||||
shell-app-system.c \
|
||||
@ -125,7 +128,7 @@ test_recorder_SOURCES = \
|
||||
endif BUILD_RECORDER
|
||||
|
||||
libgnome_shell_la_gir_sources = \
|
||||
$(filter-out $(non_gir_sources), $(libgnome_shell_la_SOURCES))
|
||||
$(filter-out $(non_gir_sources) $(non_gir_toolkit_sources), $(libgnome_shell_la_SOURCES) $(toolkit_sources))
|
||||
|
||||
shell-marshal.h: stamp-shell-marshal.h
|
||||
@true
|
||||
@ -152,15 +155,16 @@ libgnome_shell_la_LIBADD = \
|
||||
$(MUTTER_PLUGIN_LIBS) \
|
||||
$(LIBGNOMEUI_LIBS) \
|
||||
libbig-1.0.la \
|
||||
libst-1.0.la \
|
||||
libnbtk-1.0.la \
|
||||
libgdmuser-1.0.la \
|
||||
libshell-toolkit.la \
|
||||
libtray.la
|
||||
libgnome_shell_la_CPPFLAGS = $(gnome_shell_cflags)
|
||||
|
||||
typelibdir = $(pkglibdir)
|
||||
typelib_DATA = Shell-0.1.typelib Big-1.0.typelib St-1.0.typelib
|
||||
typelib_DATA = Shell-0.1.typelib Big-1.0.typelib Nbtk-1.0.typelib
|
||||
|
||||
Shell-0.1.gir: $(mutter) $(G_IR_SCANNER) Big-1.0.gir St-1.0.gir libgnome-shell.la Makefile
|
||||
Shell-0.1.gir: $(mutter) $(G_IR_SCANNER) Big-1.0.gir Nbtk-1.0.gir libgnome-shell.la Makefile
|
||||
$(AM_V_GEN) $(G_IR_SCANNER) \
|
||||
--namespace=Shell \
|
||||
--nsversion=0.1 \
|
||||
@ -170,7 +174,7 @@ Shell-0.1.gir: $(mutter) $(G_IR_SCANNER) Big-1.0.gir St-1.0.gir libgnome-shell.l
|
||||
--libtool="$(LIBTOOL)" \
|
||||
--add-include-path=$(builddir) \
|
||||
--include=Big-1.0 \
|
||||
--include=St-1.0 \
|
||||
--include=Nbtk-1.0 \
|
||||
--program=mutter \
|
||||
--program-arg=--mutter-plugins=$$(pwd)/libgnome-shell.la \
|
||||
$(addprefix $(srcdir)/,$(libgnome_shell_la_gir_sources)) \
|
||||
@ -208,25 +212,51 @@ Big-1.0.typelib: libbig-1.0.la Big-1.0.gir
|
||||
$(AM_V_GEN) $(G_IR_COMPILER) Big-1.0.gir -o $@
|
||||
CLEANFILES += Big-1.0.typelib
|
||||
|
||||
St-1.0.gir: $(mutter) $(G_IR_SCANNER) libgnome-shell.la libst-1.0.la Makefile
|
||||
toolkit_gir_sources = \
|
||||
$(filter-out $(non_gir_toolkit_sources), $(toolkit_sources))
|
||||
|
||||
# Since the Shell namepace includes both the code in toolkit/ that our fork of
|
||||
# NBTK depends upon and the code in this directory that depends on NBTK, We have a
|
||||
# circular dependency when generating the girs and typelibs. We work around this
|
||||
# by generating a Toolkit gir, using it to build the Nbtk gir then sed'ing the
|
||||
# reference out of the generated gir.
|
||||
Toolkit-0.1.gir: $(mutter) $(G_IR_SCANNER) libgnome-shell.la libshell-toolkit.la Makefile
|
||||
$(AM_V_GEN) $(G_IR_SCANNER) \
|
||||
--namespace=St \
|
||||
--nsversion=1.0 \
|
||||
--namespace=Shell \
|
||||
--nsversion=0.1 \
|
||||
--include=Clutter-1.0 \
|
||||
--add-include-path=$(builddir) \
|
||||
--libtool="$(LIBTOOL)" \
|
||||
--program=mutter \
|
||||
--program-arg=--mutter-plugins=$$(pwd)/libgnome-shell.la \
|
||||
-DST_COMPILATION \
|
||||
$(addprefix $(srcdir)/,$(st_source_h)) \
|
||||
$(addprefix $(srcdir)/,$(st_source_c)) \
|
||||
$(srcdir)/st-enum-types.h \
|
||||
$(ST_CFLAGS) \
|
||||
$(addprefix $(srcdir)/,$(toolkit_gir_sources)) \
|
||||
$(TOOLKIT_CFLAGS) \
|
||||
-o $@
|
||||
CLEANFILES += St-1.0.gir
|
||||
CLEANFILES += Toolkit-1.0.gir
|
||||
|
||||
St-1.0.typelib: St-1.0.gir
|
||||
Nbtk-1.0.gir: $(mutter) $(G_IR_SCANNER) Toolkit-0.1.gir libgnome-shell.la libnbtk-1.0.la Makefile
|
||||
$(AM_V_GEN) $(G_IR_SCANNER) \
|
||||
--namespace=Nbtk \
|
||||
--nsversion=1.0 \
|
||||
--include=Clutter-1.0 \
|
||||
--include=Gtk-2.0 \
|
||||
--add-include-path=$(builddir) \
|
||||
--include=Toolkit-0.1 \
|
||||
--libtool="$(LIBTOOL)" \
|
||||
--program=mutter \
|
||||
--program-arg=--mutter-plugins=$$(pwd)/libgnome-shell.la \
|
||||
-DNBTK_COMPILATION \
|
||||
$(addprefix $(srcdir)/,$(nbtk_source_h)) \
|
||||
$(addprefix $(srcdir)/,$(nbtk_source_c)) \
|
||||
$(srcdir)/nbtk-enum-types.h \
|
||||
$(NBTK_CFLAGS) \
|
||||
-o $@.tmp && \
|
||||
sed -e '/"Toolkit"/d' < $@.tmp > $@
|
||||
CLEANFILES += Nbtk-1.0.gir
|
||||
|
||||
Nbtk-1.0.typelib: Nbtk-1.0.gir
|
||||
$(AM_V_GEN) $(G_IR_COMPILER) \
|
||||
--includedir=. \
|
||||
--includedir=$(MUTTER_LIB_DIR)/mutter/ \
|
||||
$< -o $@
|
||||
|
||||
CLEANFILES += St-1.0.typelib
|
||||
CLEANFILES += Nbtk-1.0.typelib
|
||||
|
@ -192,6 +192,13 @@ gnome_shell_plugin_constructed (GObject *object)
|
||||
shell_plugin->gjs_context = gjs_context_new_with_search_path(search_path);
|
||||
g_strfreev(search_path);
|
||||
|
||||
shell_plugin->panel_action = XInternAtom (meta_display_get_xdisplay (display),
|
||||
"_GNOME_PANEL_ACTION", FALSE);
|
||||
shell_plugin->panel_action_run_dialog = XInternAtom (meta_display_get_xdisplay (display),
|
||||
"_GNOME_PANEL_ACTION_RUN_DIALOG", FALSE);
|
||||
shell_plugin->panel_action_main_menu = XInternAtom (meta_display_get_xdisplay (display),
|
||||
"_GNOME_PANEL_ACTION_MAIN_MENU", FALSE);
|
||||
|
||||
if (!gjs_context_eval (shell_plugin->gjs_context,
|
||||
"const Main = imports.ui.main; Main.start();",
|
||||
-1,
|
||||
@ -311,10 +318,48 @@ gnome_shell_plugin_kill_effect (MutterPlugin *plugin,
|
||||
actor, events);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
handle_panel_event (GnomeShellPlugin *shell_plugin,
|
||||
XEvent *xev)
|
||||
{
|
||||
MutterPlugin *plugin = MUTTER_PLUGIN (shell_plugin);
|
||||
MetaScreen *screen;
|
||||
MetaDisplay *display;
|
||||
XClientMessageEvent *xev_client;
|
||||
Window root;
|
||||
|
||||
screen = mutter_plugin_get_screen (plugin);
|
||||
display = meta_screen_get_display (screen);
|
||||
|
||||
if (xev->type != ClientMessage)
|
||||
return FALSE;
|
||||
|
||||
root = meta_screen_get_xroot (screen);
|
||||
|
||||
xev_client = (XClientMessageEvent*) xev;
|
||||
if (!(xev_client->window == root &&
|
||||
xev_client->message_type == shell_plugin->panel_action &&
|
||||
xev_client->format == 32))
|
||||
return FALSE;
|
||||
|
||||
if (xev_client->data.l[0] == shell_plugin->panel_action_run_dialog)
|
||||
g_signal_emit_by_name (shell_global_get (), "panel-run-dialog",
|
||||
(guint32) xev_client->data.l[1]);
|
||||
else if (xev_client->data.l[0] == shell_plugin->panel_action_main_menu)
|
||||
g_signal_emit_by_name (shell_global_get (), "panel-main-menu",
|
||||
(guint32) xev_client->data.l[1]);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnome_shell_plugin_xevent_filter (MutterPlugin *plugin,
|
||||
XEvent *xev)
|
||||
{
|
||||
GnomeShellPlugin *shell_plugin = GNOME_SHELL_PLUGIN (plugin);
|
||||
|
||||
if (handle_panel_event (shell_plugin, xev))
|
||||
return TRUE;
|
||||
return clutter_x11_handle_event (xev) != CLUTTER_X11_FILTER_CONTINUE;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-adjustment.c: Adjustment object
|
||||
* nbtk-adjustment.c: Adjustment object
|
||||
*
|
||||
* Copyright (C) 2008 OpenedHand
|
||||
* Copyright (c) 2009 Intel Corporation.
|
||||
@ -19,18 +18,10 @@
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Written by: Chris Lord <chris@openedhand.com>, inspired by GtkAdjustment
|
||||
* Port to St by: Robert Staudinger <robsta@openedhand.com>
|
||||
* Port to Nbtk by: Robert Staudinger <robsta@openedhand.com>
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:st-adjustment
|
||||
* @short_description: A GObject representing an adjustable bounded value
|
||||
*
|
||||
* The #StAdjustment object represents a range of values bounded between a
|
||||
* minimum and maximum, together with step and page increments and a page size.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
@ -38,31 +29,31 @@
|
||||
#include <glib-object.h>
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
#include "st-adjustment.h"
|
||||
#include "st-marshal.h"
|
||||
#include "st-private.h"
|
||||
#include "nbtk-adjustment.h"
|
||||
#include "nbtk-marshal.h"
|
||||
#include "nbtk-private.h"
|
||||
|
||||
G_DEFINE_TYPE (StAdjustment, st_adjustment, G_TYPE_OBJECT)
|
||||
G_DEFINE_TYPE (NbtkAdjustment, nbtk_adjustment, G_TYPE_OBJECT)
|
||||
|
||||
#define ADJUSTMENT_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ST_TYPE_ADJUSTMENT, StAdjustmentPrivate))
|
||||
#define ADJUSTMENT_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NBTK_TYPE_ADJUSTMENT, NbtkAdjustmentPrivate))
|
||||
|
||||
struct _StAdjustmentPrivate
|
||||
struct _NbtkAdjustmentPrivate
|
||||
{
|
||||
/* Do not sanity-check values while constructing,
|
||||
* not all properties may be set yet. */
|
||||
gboolean is_constructing : 1;
|
||||
|
||||
gdouble lower;
|
||||
gdouble upper;
|
||||
gdouble value;
|
||||
gdouble step_increment;
|
||||
gdouble page_increment;
|
||||
gdouble page_size;
|
||||
gdouble lower;
|
||||
gdouble upper;
|
||||
gdouble value;
|
||||
gdouble step_increment;
|
||||
gdouble page_increment;
|
||||
gdouble page_size;
|
||||
|
||||
/* For interpolation */
|
||||
ClutterTimeline *interpolation;
|
||||
gdouble old_position;
|
||||
gdouble new_position;
|
||||
gdouble old_position;
|
||||
gdouble new_position;
|
||||
|
||||
/* For elasticity */
|
||||
gboolean elastic;
|
||||
@ -93,43 +84,43 @@ enum
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0, };
|
||||
|
||||
static gboolean st_adjustment_set_lower (StAdjustment *adjustment,
|
||||
gdouble lower);
|
||||
static gboolean st_adjustment_set_upper (StAdjustment *adjustment,
|
||||
gdouble upper);
|
||||
static gboolean st_adjustment_set_step_increment (StAdjustment *adjustment,
|
||||
gdouble step);
|
||||
static gboolean st_adjustment_set_page_increment (StAdjustment *adjustment,
|
||||
gdouble page);
|
||||
static gboolean st_adjustment_set_page_size (StAdjustment *adjustment,
|
||||
gdouble size);
|
||||
static gboolean nbtk_adjustment_set_lower (NbtkAdjustment *adjustment,
|
||||
gdouble lower);
|
||||
static gboolean nbtk_adjustment_set_upper (NbtkAdjustment *adjustment,
|
||||
gdouble upper);
|
||||
static gboolean nbtk_adjustment_set_step_increment (NbtkAdjustment *adjustment,
|
||||
gdouble step);
|
||||
static gboolean nbtk_adjustment_set_page_increment (NbtkAdjustment *adjustment,
|
||||
gdouble page);
|
||||
static gboolean nbtk_adjustment_set_page_size (NbtkAdjustment *adjustment,
|
||||
gdouble size);
|
||||
|
||||
static void
|
||||
st_adjustment_constructed (GObject *object)
|
||||
nbtk_adjustment_constructed (GObject *object)
|
||||
{
|
||||
GObjectClass *g_class;
|
||||
StAdjustment *self = ST_ADJUSTMENT (object);
|
||||
NbtkAdjustment *self = NBTK_ADJUSTMENT (object);
|
||||
|
||||
g_class = G_OBJECT_CLASS (st_adjustment_parent_class);
|
||||
g_class = G_OBJECT_CLASS (nbtk_adjustment_parent_class);
|
||||
/* The docs say we're suppose to chain up, but would crash without
|
||||
* some extra care. */
|
||||
if (g_class && g_class->constructed &&
|
||||
g_class->constructed != st_adjustment_constructed)
|
||||
g_class->constructed != nbtk_adjustment_constructed)
|
||||
{
|
||||
g_class->constructed (object);
|
||||
}
|
||||
|
||||
ST_ADJUSTMENT (self)->priv->is_constructing = FALSE;
|
||||
st_adjustment_clamp_page (self, self->priv->lower, self->priv->upper);
|
||||
NBTK_ADJUSTMENT (self)->priv->is_constructing = FALSE;
|
||||
nbtk_adjustment_clamp_page (self, self->priv->lower, self->priv->upper);
|
||||
}
|
||||
|
||||
static void
|
||||
st_adjustment_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
nbtk_adjustment_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StAdjustmentPrivate *priv = ST_ADJUSTMENT (gobject)->priv;
|
||||
NbtkAdjustmentPrivate *priv = NBTK_ADJUSTMENT (gobject)->priv;
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
@ -168,41 +159,41 @@ st_adjustment_get_property (GObject *gobject,
|
||||
}
|
||||
|
||||
static void
|
||||
st_adjustment_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
nbtk_adjustment_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StAdjustment *adj = ST_ADJUSTMENT (gobject);
|
||||
NbtkAdjustment *adj = NBTK_ADJUSTMENT (gobject);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_LOWER:
|
||||
st_adjustment_set_lower (adj, g_value_get_double (value));
|
||||
nbtk_adjustment_set_lower (adj, g_value_get_double (value));
|
||||
break;
|
||||
|
||||
case PROP_UPPER:
|
||||
st_adjustment_set_upper (adj, g_value_get_double (value));
|
||||
nbtk_adjustment_set_upper (adj, g_value_get_double (value));
|
||||
break;
|
||||
|
||||
case PROP_VALUE:
|
||||
st_adjustment_set_value (adj, g_value_get_double (value));
|
||||
nbtk_adjustment_set_value (adj, g_value_get_double (value));
|
||||
break;
|
||||
|
||||
case PROP_STEP_INC:
|
||||
st_adjustment_set_step_increment (adj, g_value_get_double (value));
|
||||
nbtk_adjustment_set_step_increment (adj, g_value_get_double (value));
|
||||
break;
|
||||
|
||||
case PROP_PAGE_INC:
|
||||
st_adjustment_set_page_increment (adj, g_value_get_double (value));
|
||||
nbtk_adjustment_set_page_increment (adj, g_value_get_double (value));
|
||||
break;
|
||||
|
||||
case PROP_PAGE_SIZE:
|
||||
st_adjustment_set_page_size (adj, g_value_get_double (value));
|
||||
nbtk_adjustment_set_page_size (adj, g_value_get_double (value));
|
||||
break;
|
||||
|
||||
case PROP_ELASTIC:
|
||||
st_adjustment_set_elastic (adj, g_value_get_boolean (value));
|
||||
nbtk_adjustment_set_elastic (adj, g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -212,9 +203,9 @@ st_adjustment_set_property (GObject *gobject,
|
||||
}
|
||||
|
||||
static void
|
||||
stop_interpolation (StAdjustment *adjustment)
|
||||
stop_interpolation (NbtkAdjustment *adjustment)
|
||||
{
|
||||
StAdjustmentPrivate *priv = adjustment->priv;
|
||||
NbtkAdjustmentPrivate *priv = adjustment->priv;
|
||||
|
||||
if (priv->interpolation)
|
||||
{
|
||||
@ -237,24 +228,24 @@ stop_interpolation (StAdjustment *adjustment)
|
||||
}
|
||||
|
||||
static void
|
||||
st_adjustment_dispose (GObject *object)
|
||||
nbtk_adjustment_dispose (GObject *object)
|
||||
{
|
||||
stop_interpolation (ST_ADJUSTMENT (object));
|
||||
stop_interpolation (NBTK_ADJUSTMENT (object));
|
||||
|
||||
G_OBJECT_CLASS (st_adjustment_parent_class)->dispose (object);
|
||||
G_OBJECT_CLASS (nbtk_adjustment_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
st_adjustment_class_init (StAdjustmentClass *klass)
|
||||
nbtk_adjustment_class_init (NbtkAdjustmentClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
g_type_class_add_private (klass, sizeof (StAdjustmentPrivate));
|
||||
g_type_class_add_private (klass, sizeof (NbtkAdjustmentPrivate));
|
||||
|
||||
object_class->constructed = st_adjustment_constructed;
|
||||
object_class->get_property = st_adjustment_get_property;
|
||||
object_class->set_property = st_adjustment_set_property;
|
||||
object_class->dispose = st_adjustment_dispose;
|
||||
object_class->constructed = nbtk_adjustment_constructed;
|
||||
object_class->get_property = nbtk_adjustment_get_property;
|
||||
object_class->set_property = nbtk_adjustment_set_property;
|
||||
object_class->dispose = nbtk_adjustment_dispose;
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_LOWER,
|
||||
@ -264,7 +255,7 @@ st_adjustment_class_init (StAdjustmentClass *klass)
|
||||
-G_MAXDOUBLE,
|
||||
G_MAXDOUBLE,
|
||||
0.0,
|
||||
ST_PARAM_READWRITE |
|
||||
NBTK_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_UPPER,
|
||||
@ -274,7 +265,7 @@ st_adjustment_class_init (StAdjustmentClass *klass)
|
||||
-G_MAXDOUBLE,
|
||||
G_MAXDOUBLE,
|
||||
0.0,
|
||||
ST_PARAM_READWRITE |
|
||||
NBTK_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_VALUE,
|
||||
@ -284,7 +275,7 @@ st_adjustment_class_init (StAdjustmentClass *klass)
|
||||
-G_MAXDOUBLE,
|
||||
G_MAXDOUBLE,
|
||||
0.0,
|
||||
ST_PARAM_READWRITE |
|
||||
NBTK_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_STEP_INC,
|
||||
@ -294,7 +285,7 @@ st_adjustment_class_init (StAdjustmentClass *klass)
|
||||
0.0,
|
||||
G_MAXDOUBLE,
|
||||
0.0,
|
||||
ST_PARAM_READWRITE |
|
||||
NBTK_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_PAGE_INC,
|
||||
@ -304,7 +295,7 @@ st_adjustment_class_init (StAdjustmentClass *klass)
|
||||
0.0,
|
||||
G_MAXDOUBLE,
|
||||
0.0,
|
||||
ST_PARAM_READWRITE |
|
||||
NBTK_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_PAGE_SIZE,
|
||||
@ -314,7 +305,7 @@ st_adjustment_class_init (StAdjustmentClass *klass)
|
||||
0.0,
|
||||
G_MAXDOUBLE,
|
||||
0.0,
|
||||
ST_PARAM_READWRITE |
|
||||
NBTK_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_ELASTIC,
|
||||
@ -325,11 +316,11 @@ st_adjustment_class_init (StAdjustmentClass *klass)
|
||||
"'elastic' way and "
|
||||
"stop clamping value.",
|
||||
FALSE,
|
||||
ST_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
NBTK_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
|
||||
/**
|
||||
* StAdjustment::changed:
|
||||
* NbtkAdjustment::changed:
|
||||
*
|
||||
* Emitted when any of the adjustment values have changed
|
||||
*/
|
||||
@ -337,29 +328,29 @@ st_adjustment_class_init (StAdjustmentClass *klass)
|
||||
g_signal_new ("changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (StAdjustmentClass, changed),
|
||||
G_STRUCT_OFFSET (NbtkAdjustmentClass, changed),
|
||||
NULL, NULL,
|
||||
_st_marshal_VOID__VOID,
|
||||
_nbtk_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
st_adjustment_init (StAdjustment *self)
|
||||
nbtk_adjustment_init (NbtkAdjustment *self)
|
||||
{
|
||||
self->priv = ADJUSTMENT_PRIVATE (self);
|
||||
|
||||
self->priv->is_constructing = TRUE;
|
||||
}
|
||||
|
||||
StAdjustment *
|
||||
st_adjustment_new (gdouble value,
|
||||
gdouble lower,
|
||||
gdouble upper,
|
||||
gdouble step_increment,
|
||||
gdouble page_increment,
|
||||
gdouble page_size)
|
||||
NbtkAdjustment *
|
||||
nbtk_adjustment_new (gdouble value,
|
||||
gdouble lower,
|
||||
gdouble upper,
|
||||
gdouble step_increment,
|
||||
gdouble page_increment,
|
||||
gdouble page_size)
|
||||
{
|
||||
return g_object_new (ST_TYPE_ADJUSTMENT,
|
||||
return g_object_new (NBTK_TYPE_ADJUSTMENT,
|
||||
"value", value,
|
||||
"lower", lower,
|
||||
"upper", upper,
|
||||
@ -370,11 +361,11 @@ st_adjustment_new (gdouble value,
|
||||
}
|
||||
|
||||
gdouble
|
||||
st_adjustment_get_value (StAdjustment *adjustment)
|
||||
nbtk_adjustment_get_value (NbtkAdjustment *adjustment)
|
||||
{
|
||||
StAdjustmentPrivate *priv;
|
||||
NbtkAdjustmentPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (ST_IS_ADJUSTMENT (adjustment), 0);
|
||||
g_return_val_if_fail (NBTK_IS_ADJUSTMENT (adjustment), 0);
|
||||
|
||||
priv = adjustment->priv;
|
||||
|
||||
@ -389,12 +380,12 @@ st_adjustment_get_value (StAdjustment *adjustment)
|
||||
}
|
||||
|
||||
void
|
||||
st_adjustment_set_value (StAdjustment *adjustment,
|
||||
gdouble value)
|
||||
nbtk_adjustment_set_value (NbtkAdjustment *adjustment,
|
||||
gdouble value)
|
||||
{
|
||||
StAdjustmentPrivate *priv;
|
||||
NbtkAdjustmentPrivate *priv;
|
||||
|
||||
g_return_if_fail (ST_IS_ADJUSTMENT (adjustment));
|
||||
g_return_if_fail (NBTK_IS_ADJUSTMENT (adjustment));
|
||||
|
||||
priv = adjustment->priv;
|
||||
|
||||
@ -418,14 +409,14 @@ st_adjustment_set_value (StAdjustment *adjustment,
|
||||
}
|
||||
|
||||
void
|
||||
st_adjustment_clamp_page (StAdjustment *adjustment,
|
||||
gdouble lower,
|
||||
gdouble upper)
|
||||
nbtk_adjustment_clamp_page (NbtkAdjustment *adjustment,
|
||||
gdouble lower,
|
||||
gdouble upper)
|
||||
{
|
||||
StAdjustmentPrivate *priv;
|
||||
NbtkAdjustmentPrivate *priv;
|
||||
gboolean changed;
|
||||
|
||||
g_return_if_fail (ST_IS_ADJUSTMENT (adjustment));
|
||||
g_return_if_fail (NBTK_IS_ADJUSTMENT (adjustment));
|
||||
|
||||
priv = adjustment->priv;
|
||||
|
||||
@ -453,10 +444,10 @@ st_adjustment_clamp_page (StAdjustment *adjustment,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
st_adjustment_set_lower (StAdjustment *adjustment,
|
||||
gdouble lower)
|
||||
nbtk_adjustment_set_lower (NbtkAdjustment *adjustment,
|
||||
gdouble lower)
|
||||
{
|
||||
StAdjustmentPrivate *priv = adjustment->priv;
|
||||
NbtkAdjustmentPrivate *priv = adjustment->priv;
|
||||
|
||||
if (priv->lower != lower)
|
||||
{
|
||||
@ -468,7 +459,7 @@ st_adjustment_set_lower (StAdjustment *adjustment,
|
||||
|
||||
/* Defer clamp until after construction. */
|
||||
if (!priv->is_constructing)
|
||||
st_adjustment_clamp_page (adjustment, priv->lower, priv->upper);
|
||||
nbtk_adjustment_clamp_page (adjustment, priv->lower, priv->upper);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -477,10 +468,10 @@ st_adjustment_set_lower (StAdjustment *adjustment,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
st_adjustment_set_upper (StAdjustment *adjustment,
|
||||
gdouble upper)
|
||||
nbtk_adjustment_set_upper (NbtkAdjustment *adjustment,
|
||||
gdouble upper)
|
||||
{
|
||||
StAdjustmentPrivate *priv = adjustment->priv;
|
||||
NbtkAdjustmentPrivate *priv = adjustment->priv;
|
||||
|
||||
if (priv->upper != upper)
|
||||
{
|
||||
@ -492,7 +483,7 @@ st_adjustment_set_upper (StAdjustment *adjustment,
|
||||
|
||||
/* Defer clamp until after construction. */
|
||||
if (!priv->is_constructing)
|
||||
st_adjustment_clamp_page (adjustment, priv->lower, priv->upper);
|
||||
nbtk_adjustment_clamp_page (adjustment, priv->lower, priv->upper);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -501,10 +492,10 @@ st_adjustment_set_upper (StAdjustment *adjustment,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
st_adjustment_set_step_increment (StAdjustment *adjustment,
|
||||
gdouble step)
|
||||
nbtk_adjustment_set_step_increment (NbtkAdjustment *adjustment,
|
||||
gdouble step)
|
||||
{
|
||||
StAdjustmentPrivate *priv = adjustment->priv;
|
||||
NbtkAdjustmentPrivate *priv = adjustment->priv;
|
||||
|
||||
if (priv->step_increment != step)
|
||||
{
|
||||
@ -521,10 +512,10 @@ st_adjustment_set_step_increment (StAdjustment *adjustment,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
st_adjustment_set_page_increment (StAdjustment *adjustment,
|
||||
gdouble page)
|
||||
nbtk_adjustment_set_page_increment (NbtkAdjustment *adjustment,
|
||||
gdouble page)
|
||||
{
|
||||
StAdjustmentPrivate *priv = adjustment->priv;
|
||||
NbtkAdjustmentPrivate *priv = adjustment->priv;
|
||||
|
||||
if (priv->page_increment != page)
|
||||
{
|
||||
@ -541,10 +532,10 @@ st_adjustment_set_page_increment (StAdjustment *adjustment,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
st_adjustment_set_page_size (StAdjustment *adjustment,
|
||||
gdouble size)
|
||||
nbtk_adjustment_set_page_size (NbtkAdjustment *adjustment,
|
||||
gdouble size)
|
||||
{
|
||||
StAdjustmentPrivate *priv = adjustment->priv;
|
||||
NbtkAdjustmentPrivate *priv = adjustment->priv;
|
||||
|
||||
if (priv->page_size != size)
|
||||
{
|
||||
@ -556,7 +547,7 @@ st_adjustment_set_page_size (StAdjustment *adjustment,
|
||||
|
||||
/* Well explicitely clamp after construction. */
|
||||
if (!priv->is_constructing)
|
||||
st_adjustment_clamp_page (adjustment, priv->lower, priv->upper);
|
||||
nbtk_adjustment_clamp_page (adjustment, priv->lower, priv->upper);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -565,18 +556,18 @@ st_adjustment_set_page_size (StAdjustment *adjustment,
|
||||
}
|
||||
|
||||
void
|
||||
st_adjustment_set_values (StAdjustment *adjustment,
|
||||
gdouble value,
|
||||
gdouble lower,
|
||||
gdouble upper,
|
||||
gdouble step_increment,
|
||||
gdouble page_increment,
|
||||
gdouble page_size)
|
||||
nbtk_adjustment_set_values (NbtkAdjustment *adjustment,
|
||||
gdouble value,
|
||||
gdouble lower,
|
||||
gdouble upper,
|
||||
gdouble step_increment,
|
||||
gdouble page_increment,
|
||||
gdouble page_size)
|
||||
{
|
||||
StAdjustmentPrivate *priv;
|
||||
NbtkAdjustmentPrivate *priv;
|
||||
gboolean emit_changed = FALSE;
|
||||
|
||||
g_return_if_fail (ST_IS_ADJUSTMENT (adjustment));
|
||||
g_return_if_fail (NBTK_IS_ADJUSTMENT (adjustment));
|
||||
g_return_if_fail (page_size >= 0 && page_size <= G_MAXDOUBLE);
|
||||
g_return_if_fail (step_increment >= 0 && step_increment <= G_MAXDOUBLE);
|
||||
g_return_if_fail (page_increment >= 0 && page_increment <= G_MAXDOUBLE);
|
||||
@ -589,15 +580,15 @@ st_adjustment_set_values (StAdjustment *adjustment,
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (adjustment));
|
||||
|
||||
emit_changed |= st_adjustment_set_lower (adjustment, lower);
|
||||
emit_changed |= st_adjustment_set_upper (adjustment, upper);
|
||||
emit_changed |= st_adjustment_set_step_increment (adjustment, step_increment);
|
||||
emit_changed |= st_adjustment_set_page_increment (adjustment, page_increment);
|
||||
emit_changed |= st_adjustment_set_page_size (adjustment, page_size);
|
||||
emit_changed |= nbtk_adjustment_set_lower (adjustment, lower);
|
||||
emit_changed |= nbtk_adjustment_set_upper (adjustment, upper);
|
||||
emit_changed |= nbtk_adjustment_set_step_increment (adjustment, step_increment);
|
||||
emit_changed |= nbtk_adjustment_set_page_increment (adjustment, page_increment);
|
||||
emit_changed |= nbtk_adjustment_set_page_size (adjustment, page_size);
|
||||
|
||||
if (value != priv->value)
|
||||
{
|
||||
st_adjustment_set_value (adjustment, value);
|
||||
nbtk_adjustment_set_value (adjustment, value);
|
||||
emit_changed = TRUE;
|
||||
}
|
||||
|
||||
@ -608,17 +599,17 @@ st_adjustment_set_values (StAdjustment *adjustment,
|
||||
}
|
||||
|
||||
void
|
||||
st_adjustment_get_values (StAdjustment *adjustment,
|
||||
gdouble *value,
|
||||
gdouble *lower,
|
||||
gdouble *upper,
|
||||
gdouble *step_increment,
|
||||
gdouble *page_increment,
|
||||
gdouble *page_size)
|
||||
nbtk_adjustment_get_values (NbtkAdjustment *adjustment,
|
||||
gdouble *value,
|
||||
gdouble *lower,
|
||||
gdouble *upper,
|
||||
gdouble *step_increment,
|
||||
gdouble *page_increment,
|
||||
gdouble *page_size)
|
||||
{
|
||||
StAdjustmentPrivate *priv;
|
||||
NbtkAdjustmentPrivate *priv;
|
||||
|
||||
g_return_if_fail (ST_IS_ADJUSTMENT (adjustment));
|
||||
g_return_if_fail (NBTK_IS_ADJUSTMENT (adjustment));
|
||||
|
||||
priv = adjustment->priv;
|
||||
|
||||
@ -629,7 +620,7 @@ st_adjustment_get_values (StAdjustment *adjustment,
|
||||
*upper = priv->upper;
|
||||
|
||||
if (value)
|
||||
*value = st_adjustment_get_value (adjustment);
|
||||
*value = nbtk_adjustment_get_value (adjustment);
|
||||
|
||||
if (step_increment)
|
||||
*step_increment = priv->step_increment;
|
||||
@ -644,9 +635,9 @@ st_adjustment_get_values (StAdjustment *adjustment,
|
||||
static void
|
||||
interpolation_new_frame_cb (ClutterTimeline *timeline,
|
||||
guint msecs,
|
||||
StAdjustment *adjustment)
|
||||
NbtkAdjustment *adjustment)
|
||||
{
|
||||
StAdjustmentPrivate *priv = adjustment->priv;
|
||||
NbtkAdjustmentPrivate *priv = adjustment->priv;
|
||||
|
||||
priv->interpolation = NULL;
|
||||
|
||||
@ -654,28 +645,28 @@ interpolation_new_frame_cb (ClutterTimeline *timeline,
|
||||
{
|
||||
gdouble progress = clutter_alpha_get_alpha (priv->bounce_alpha) / 1.0;
|
||||
gdouble dx = priv->old_position
|
||||
+ (priv->new_position - priv->old_position)
|
||||
* progress;
|
||||
+ (priv->new_position - priv->old_position)
|
||||
* progress;
|
||||
|
||||
st_adjustment_set_value (adjustment, dx);
|
||||
nbtk_adjustment_set_value (adjustment, dx);
|
||||
}
|
||||
else
|
||||
st_adjustment_set_value (adjustment,
|
||||
priv->old_position +
|
||||
(priv->new_position - priv->old_position) *
|
||||
clutter_timeline_get_progress (timeline));
|
||||
nbtk_adjustment_set_value (adjustment,
|
||||
priv->old_position +
|
||||
(priv->new_position - priv->old_position) *
|
||||
clutter_timeline_get_progress (timeline));
|
||||
|
||||
priv->interpolation = timeline;
|
||||
}
|
||||
|
||||
static void
|
||||
interpolation_completed_cb (ClutterTimeline *timeline,
|
||||
StAdjustment *adjustment)
|
||||
NbtkAdjustment *adjustment)
|
||||
{
|
||||
StAdjustmentPrivate *priv = adjustment->priv;
|
||||
NbtkAdjustmentPrivate *priv = adjustment->priv;
|
||||
|
||||
stop_interpolation (adjustment);
|
||||
st_adjustment_set_value (adjustment, priv->new_position);
|
||||
nbtk_adjustment_set_value (adjustment, priv->new_position);
|
||||
}
|
||||
|
||||
/* Note, there's super-optimal code that does a similar thing in
|
||||
@ -685,33 +676,33 @@ interpolation_completed_cb (ClutterTimeline *timeline,
|
||||
* better. Leaving code here in case this is revisited.
|
||||
*/
|
||||
/*
|
||||
static guint32
|
||||
bounce_alpha_func (ClutterAlpha *alpha,
|
||||
static guint32
|
||||
bounce_alpha_func (ClutterAlpha *alpha,
|
||||
gpointer user_data)
|
||||
{
|
||||
ClutterFixed progress, angle;
|
||||
ClutterTimeline *timeline = clutter_alpha_get_timeline (alpha);
|
||||
{
|
||||
ClutterFixed progress, angle;
|
||||
ClutterTimeline *timeline = clutter_alpha_get_timeline (alpha);
|
||||
|
||||
progress = clutter_timeline_get_progressx (timeline);
|
||||
angle = clutter_qmulx (CFX_PI_2 + CFX_PI_4/2, progress);
|
||||
progress = clutter_timeline_get_progressx (timeline);
|
||||
angle = clutter_qmulx (CFX_PI_2 + CFX_PI_4/2, progress);
|
||||
|
||||
return clutter_sinx (angle) +
|
||||
return clutter_sinx (angle) +
|
||||
(CFX_ONE - clutter_sinx (CFX_PI_2 + CFX_PI_4/2));
|
||||
}
|
||||
*/
|
||||
}
|
||||
*/
|
||||
|
||||
void
|
||||
st_adjustment_interpolate (StAdjustment *adjustment,
|
||||
gdouble value,
|
||||
guint duration)
|
||||
nbtk_adjustment_interpolate (NbtkAdjustment *adjustment,
|
||||
gdouble value,
|
||||
guint duration)
|
||||
{
|
||||
StAdjustmentPrivate *priv = adjustment->priv;
|
||||
NbtkAdjustmentPrivate *priv = adjustment->priv;
|
||||
|
||||
stop_interpolation (adjustment);
|
||||
|
||||
if (duration <= 1)
|
||||
{
|
||||
st_adjustment_set_value (adjustment, value);
|
||||
nbtk_adjustment_set_value (adjustment, value);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -737,24 +728,24 @@ st_adjustment_interpolate (StAdjustment *adjustment,
|
||||
}
|
||||
|
||||
gboolean
|
||||
st_adjustment_get_elastic (StAdjustment *adjustment)
|
||||
nbtk_adjustment_get_elastic (NbtkAdjustment *adjustment)
|
||||
{
|
||||
return adjustment->priv->elastic;
|
||||
}
|
||||
|
||||
void
|
||||
st_adjustment_set_elastic (StAdjustment *adjustment,
|
||||
gboolean elastic)
|
||||
nbtk_adjustment_set_elastic (NbtkAdjustment *adjustment,
|
||||
gboolean elastic)
|
||||
{
|
||||
adjustment->priv->elastic = elastic;
|
||||
}
|
||||
|
||||
gboolean
|
||||
st_adjustment_clamp (StAdjustment *adjustment,
|
||||
gboolean interpolate,
|
||||
guint duration)
|
||||
nbtk_adjustment_clamp (NbtkAdjustment *adjustment,
|
||||
gboolean interpolate,
|
||||
guint duration)
|
||||
{
|
||||
StAdjustmentPrivate *priv = adjustment->priv;
|
||||
NbtkAdjustmentPrivate *priv = adjustment->priv;
|
||||
gdouble dest = priv->value;
|
||||
|
||||
if (priv->value < priv->lower)
|
||||
@ -766,9 +757,9 @@ st_adjustment_clamp (StAdjustment *adjustment,
|
||||
if (dest != priv->value)
|
||||
{
|
||||
if (interpolate)
|
||||
st_adjustment_interpolate (adjustment, dest, duration);
|
||||
nbtk_adjustment_interpolate (adjustment, dest, duration);
|
||||
else
|
||||
st_adjustment_set_value (adjustment, dest);
|
||||
nbtk_adjustment_set_value (adjustment, dest);
|
||||
|
||||
return TRUE;
|
||||
}
|
121
src/nbtk/nbtk-adjustment.h
Normal file
121
src/nbtk/nbtk-adjustment.h
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* nbtk-adjustment.h: Adjustment object
|
||||
*
|
||||
* Copyright 2008 OpenedHand
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Written by: Chris Lord <chris@openedhand.com>, inspired by GtkAdjustment
|
||||
* Port to Nbtk by: Robert Staudinger <robsta@openedhand.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(NBTK_H_INSIDE) && !defined(NBTK_COMPILATION)
|
||||
#error "Only <nbtk/nbtk.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef __NBTK_ADJUSTMENT_H__
|
||||
#define __NBTK_ADJUSTMENT_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NBTK_TYPE_ADJUSTMENT (nbtk_adjustment_get_type())
|
||||
#define NBTK_ADJUSTMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NBTK_TYPE_ADJUSTMENT, NbtkAdjustment))
|
||||
#define NBTK_IS_ADJUSTMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NBTK_TYPE_ADJUSTMENT))
|
||||
#define NBTK_ADJUSTMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NBTK_TYPE_ADJUSTMENT, NbtkAdjustmentClass))
|
||||
#define NBTK_IS_ADJUSTMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NBTK_TYPE_ADJUSTMENT))
|
||||
#define NBTK_ADJUSTMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NBTK_TYPE_ADJUSTMENT, NbtkAdjustmentClass))
|
||||
|
||||
typedef struct _NbtkAdjustment NbtkAdjustment;
|
||||
typedef struct _NbtkAdjustmentPrivate NbtkAdjustmentPrivate;
|
||||
typedef struct _NbtkAdjustmentClass NbtkAdjustmentClass;
|
||||
|
||||
/**
|
||||
* NbtkAdjustment:
|
||||
*
|
||||
* Class for handling an interval between to values. The contents of
|
||||
* the #NbtkAdjustment are private and should be accessed using the
|
||||
* public API.
|
||||
*/
|
||||
struct _NbtkAdjustment
|
||||
{
|
||||
/*< private >*/
|
||||
GObject parent_instance;
|
||||
|
||||
NbtkAdjustmentPrivate *priv;
|
||||
};
|
||||
|
||||
/**
|
||||
* NbtkAdjustmentClass
|
||||
* @changed: Class handler for the ::changed signal.
|
||||
*
|
||||
* Base class for #NbtkAdjustment.
|
||||
*/
|
||||
struct _NbtkAdjustmentClass
|
||||
{
|
||||
/*< private >*/
|
||||
GObjectClass parent_class;
|
||||
|
||||
/*< public >*/
|
||||
void (* changed) (NbtkAdjustment *adjustment);
|
||||
};
|
||||
|
||||
GType nbtk_adjustment_get_type (void) G_GNUC_CONST;
|
||||
|
||||
NbtkAdjustment *nbtk_adjustment_new (gdouble value,
|
||||
gdouble lower,
|
||||
gdouble upper,
|
||||
gdouble step_increment,
|
||||
gdouble page_increment,
|
||||
gdouble page_size);
|
||||
gdouble nbtk_adjustment_get_value (NbtkAdjustment *adjustment);
|
||||
void nbtk_adjustment_set_value (NbtkAdjustment *adjustment,
|
||||
gdouble value);
|
||||
void nbtk_adjustment_clamp_page (NbtkAdjustment *adjustment,
|
||||
gdouble lower,
|
||||
gdouble upper);
|
||||
void nbtk_adjustment_set_values (NbtkAdjustment *adjustment,
|
||||
gdouble value,
|
||||
gdouble lower,
|
||||
gdouble upper,
|
||||
gdouble step_increment,
|
||||
gdouble page_increment,
|
||||
gdouble page_size);
|
||||
void nbtk_adjustment_get_values (NbtkAdjustment *adjustment,
|
||||
gdouble *value,
|
||||
gdouble *lower,
|
||||
gdouble *upper,
|
||||
gdouble *step_increment,
|
||||
gdouble *page_increment,
|
||||
gdouble *page_size);
|
||||
|
||||
void nbtk_adjustment_interpolate (NbtkAdjustment *adjustment,
|
||||
gdouble value,
|
||||
guint duration);
|
||||
|
||||
gboolean nbtk_adjustment_get_elastic (NbtkAdjustment *adjustment);
|
||||
void nbtk_adjustment_set_elastic (NbtkAdjustment *adjustment,
|
||||
gboolean elastic);
|
||||
|
||||
gboolean nbtk_adjustment_clamp (NbtkAdjustment *adjustment,
|
||||
gboolean interpolate,
|
||||
guint duration);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NBTK_ADJUSTMENT_H__ */
|
@ -1,6 +1,5 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-bin.c: Basic container actor
|
||||
* nbtk-bin.c: Basic container actor
|
||||
*
|
||||
* Copyright (c) 2009 Intel Corporation.
|
||||
*
|
||||
@ -22,13 +21,13 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:st-bin
|
||||
* SECTION:nbtk-bin
|
||||
* @short_description: a simple container with one actor
|
||||
*
|
||||
* #StBin is a simple container capable of having only one
|
||||
* #NbtkBin is a simple container capable of having only one
|
||||
* #ClutterActor as a child.
|
||||
*
|
||||
* #StBin inherits from #StWidget, so it is fully themable.
|
||||
* #NbtkBin inherits from #NbtkWidget, so it is fully themable.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -37,21 +36,21 @@
|
||||
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
#include "st-bin.h"
|
||||
#include "st-enum-types.h"
|
||||
#include "st-private.h"
|
||||
#include "nbtk-bin.h"
|
||||
#include "nbtk-enum-types.h"
|
||||
#include "nbtk-private.h"
|
||||
|
||||
#define ST_BIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ST_TYPE_BIN, StBinPrivate))
|
||||
#define NBTK_BIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), NBTK_TYPE_BIN, NbtkBinPrivate))
|
||||
|
||||
struct _StBinPrivate
|
||||
struct _NbtkBinPrivate
|
||||
{
|
||||
ClutterActor *child;
|
||||
|
||||
StAlign x_align;
|
||||
StAlign y_align;
|
||||
NbtkAlignment x_align;
|
||||
NbtkAlignment y_align;
|
||||
|
||||
guint x_fill : 1;
|
||||
guint y_fill : 1;
|
||||
guint x_fill : 1;
|
||||
guint y_fill : 1;
|
||||
};
|
||||
|
||||
enum
|
||||
@ -67,29 +66,29 @@ enum
|
||||
|
||||
static void clutter_container_iface_init (ClutterContainerIface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (StBin, st_bin, ST_TYPE_WIDGET,
|
||||
G_DEFINE_TYPE_WITH_CODE (NbtkBin, nbtk_bin, NBTK_TYPE_WIDGET,
|
||||
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_CONTAINER,
|
||||
clutter_container_iface_init));
|
||||
|
||||
void
|
||||
_st_bin_get_align_factors (StBin *bin,
|
||||
gdouble *x_align,
|
||||
gdouble *y_align)
|
||||
_nbtk_bin_get_align_factors (NbtkBin *bin,
|
||||
gdouble *x_align,
|
||||
gdouble *y_align)
|
||||
{
|
||||
StBinPrivate *priv = bin->priv;
|
||||
NbtkBinPrivate *priv = bin->priv;
|
||||
gdouble factor;
|
||||
|
||||
switch (priv->x_align)
|
||||
{
|
||||
case ST_ALIGN_START:
|
||||
case NBTK_ALIGN_LEFT:
|
||||
factor = 0.0;
|
||||
break;
|
||||
|
||||
case ST_ALIGN_MIDDLE:
|
||||
case NBTK_ALIGN_CENTER:
|
||||
factor = 0.5;
|
||||
break;
|
||||
|
||||
case ST_ALIGN_END:
|
||||
case NBTK_ALIGN_RIGHT:
|
||||
factor = 1.0;
|
||||
break;
|
||||
|
||||
@ -103,15 +102,15 @@ _st_bin_get_align_factors (StBin *bin,
|
||||
|
||||
switch (priv->y_align)
|
||||
{
|
||||
case ST_ALIGN_START:
|
||||
case NBTK_ALIGN_TOP:
|
||||
factor = 0.0;
|
||||
break;
|
||||
|
||||
case ST_ALIGN_MIDDLE:
|
||||
case NBTK_ALIGN_CENTER:
|
||||
factor = 0.5;
|
||||
break;
|
||||
|
||||
case ST_ALIGN_END:
|
||||
case NBTK_ALIGN_BOTTOM:
|
||||
factor = 1.0;
|
||||
break;
|
||||
|
||||
@ -125,28 +124,28 @@ _st_bin_get_align_factors (StBin *bin,
|
||||
}
|
||||
|
||||
static void
|
||||
st_bin_add (ClutterContainer *container,
|
||||
ClutterActor *actor)
|
||||
nbtk_bin_add (ClutterContainer *container,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
st_bin_set_child (ST_BIN (container), actor);
|
||||
nbtk_bin_set_child (NBTK_BIN (container), actor);
|
||||
}
|
||||
|
||||
static void
|
||||
st_bin_remove (ClutterContainer *container,
|
||||
ClutterActor *actor)
|
||||
nbtk_bin_remove (ClutterContainer *container,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
StBinPrivate *priv = ST_BIN (container)->priv;
|
||||
NbtkBinPrivate *priv = NBTK_BIN (container)->priv;
|
||||
|
||||
if (priv->child == actor)
|
||||
st_bin_set_child (ST_BIN (container), NULL);
|
||||
nbtk_bin_set_child (NBTK_BIN (container), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
st_bin_foreach (ClutterContainer *container,
|
||||
ClutterCallback callback,
|
||||
gpointer user_data)
|
||||
nbtk_bin_foreach (ClutterContainer *container,
|
||||
ClutterCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
StBinPrivate *priv = ST_BIN (container)->priv;
|
||||
NbtkBinPrivate *priv = NBTK_BIN (container)->priv;
|
||||
|
||||
if (priv->child)
|
||||
callback (priv->child, user_data);
|
||||
@ -155,18 +154,18 @@ st_bin_foreach (ClutterContainer *container,
|
||||
static void
|
||||
clutter_container_iface_init (ClutterContainerIface *iface)
|
||||
{
|
||||
iface->add = st_bin_add;
|
||||
iface->remove = st_bin_remove;
|
||||
iface->foreach = st_bin_foreach;
|
||||
iface->add = nbtk_bin_add;
|
||||
iface->remove = nbtk_bin_remove;
|
||||
iface->foreach = nbtk_bin_foreach;
|
||||
}
|
||||
|
||||
static void
|
||||
st_bin_paint (ClutterActor *self)
|
||||
nbtk_bin_paint (ClutterActor *self)
|
||||
{
|
||||
StBinPrivate *priv = ST_BIN (self)->priv;
|
||||
NbtkBinPrivate *priv = NBTK_BIN (self)->priv;
|
||||
|
||||
/* allow StWidget to paint the background */
|
||||
CLUTTER_ACTOR_CLASS (st_bin_parent_class)->paint (self);
|
||||
/* allow NbtkWidget to paint the background */
|
||||
CLUTTER_ACTOR_CLASS (nbtk_bin_parent_class)->paint (self);
|
||||
|
||||
/* the pain our child */
|
||||
if (priv->child)
|
||||
@ -174,31 +173,31 @@ st_bin_paint (ClutterActor *self)
|
||||
}
|
||||
|
||||
static void
|
||||
st_bin_pick (ClutterActor *self,
|
||||
const ClutterColor *pick_color)
|
||||
nbtk_bin_pick (ClutterActor *self,
|
||||
const ClutterColor *pick_color)
|
||||
{
|
||||
StBinPrivate *priv = ST_BIN (self)->priv;
|
||||
NbtkBinPrivate *priv = NBTK_BIN (self)->priv;
|
||||
|
||||
/* get the default pick implementation */
|
||||
CLUTTER_ACTOR_CLASS (st_bin_parent_class)->pick (self, pick_color);
|
||||
CLUTTER_ACTOR_CLASS (nbtk_bin_parent_class)->pick (self, pick_color);
|
||||
|
||||
if (priv->child)
|
||||
clutter_actor_paint (priv->child);
|
||||
}
|
||||
|
||||
static void
|
||||
st_bin_allocate (ClutterActor *self,
|
||||
const ClutterActorBox *box,
|
||||
ClutterAllocationFlags flags)
|
||||
nbtk_bin_allocate (ClutterActor *self,
|
||||
const ClutterActorBox *box,
|
||||
ClutterAllocationFlags flags)
|
||||
{
|
||||
StBinPrivate *priv = ST_BIN (self)->priv;
|
||||
NbtkBinPrivate *priv = NBTK_BIN (self)->priv;
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_bin_parent_class)->allocate (self, box,
|
||||
flags);
|
||||
CLUTTER_ACTOR_CLASS (nbtk_bin_parent_class)->allocate (self, box,
|
||||
flags);
|
||||
|
||||
if (priv->child)
|
||||
{
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self));
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (self));
|
||||
gfloat natural_width, natural_height;
|
||||
gfloat min_width, min_height;
|
||||
gfloat child_width, child_height;
|
||||
@ -208,9 +207,9 @@ st_bin_allocate (ClutterActor *self,
|
||||
ClutterActorBox allocation = { 0, };
|
||||
gdouble x_align, y_align;
|
||||
|
||||
st_theme_node_get_content_box (theme_node, box, &content_box);
|
||||
shell_theme_node_get_content_box (theme_node, box, &content_box);
|
||||
|
||||
_st_bin_get_align_factors (ST_BIN (self), &x_align, &y_align);
|
||||
_nbtk_bin_get_align_factors (NBTK_BIN (self), &x_align, &y_align);
|
||||
|
||||
available_width = content_box.x2 - content_box.x1;
|
||||
available_height = content_box.y2 - content_box.y1;
|
||||
@ -289,20 +288,20 @@ st_bin_allocate (ClutterActor *self,
|
||||
}
|
||||
|
||||
static void
|
||||
st_bin_get_preferred_width (ClutterActor *self,
|
||||
gfloat for_height,
|
||||
gfloat *min_width_p,
|
||||
gfloat *natural_width_p)
|
||||
nbtk_bin_get_preferred_width (ClutterActor *self,
|
||||
gfloat for_height,
|
||||
gfloat *min_width_p,
|
||||
gfloat *natural_width_p)
|
||||
{
|
||||
StBinPrivate *priv = ST_BIN (self)->priv;
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self));
|
||||
NbtkBinPrivate *priv = NBTK_BIN (self)->priv;
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (self));
|
||||
|
||||
st_theme_node_adjust_for_height (theme_node, &for_height);
|
||||
shell_theme_node_adjust_for_height (theme_node, &for_height);
|
||||
|
||||
if (priv->child == NULL)
|
||||
{
|
||||
if (min_width_p)
|
||||
*min_width_p = 0;
|
||||
*min_width_p = 0;
|
||||
|
||||
if (natural_width_p)
|
||||
*natural_width_p = 0;
|
||||
@ -314,19 +313,19 @@ st_bin_get_preferred_width (ClutterActor *self,
|
||||
natural_width_p);
|
||||
}
|
||||
|
||||
st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p);
|
||||
shell_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p);
|
||||
}
|
||||
|
||||
static void
|
||||
st_bin_get_preferred_height (ClutterActor *self,
|
||||
gfloat for_width,
|
||||
gfloat *min_height_p,
|
||||
gfloat *natural_height_p)
|
||||
nbtk_bin_get_preferred_height (ClutterActor *self,
|
||||
gfloat for_width,
|
||||
gfloat *min_height_p,
|
||||
gfloat *natural_height_p)
|
||||
{
|
||||
StBinPrivate *priv = ST_BIN (self)->priv;
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self));
|
||||
NbtkBinPrivate *priv = NBTK_BIN (self)->priv;
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (self));
|
||||
|
||||
st_theme_node_adjust_for_width (theme_node, &for_width);
|
||||
shell_theme_node_adjust_for_width (theme_node, &for_width);
|
||||
|
||||
if (priv->child == NULL)
|
||||
{
|
||||
@ -343,13 +342,13 @@ st_bin_get_preferred_height (ClutterActor *self,
|
||||
natural_height_p);
|
||||
}
|
||||
|
||||
st_theme_node_adjust_preferred_height (theme_node, min_height_p, natural_height_p);
|
||||
shell_theme_node_adjust_preferred_height (theme_node, min_height_p, natural_height_p);
|
||||
}
|
||||
|
||||
static void
|
||||
st_bin_dispose (GObject *gobject)
|
||||
nbtk_bin_dispose (GObject *gobject)
|
||||
{
|
||||
StBinPrivate *priv = ST_BIN (gobject)->priv;
|
||||
NbtkBinPrivate *priv = NBTK_BIN (gobject)->priv;
|
||||
|
||||
if (priv->child)
|
||||
{
|
||||
@ -357,45 +356,45 @@ st_bin_dispose (GObject *gobject)
|
||||
priv->child = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (st_bin_parent_class)->dispose (gobject);
|
||||
G_OBJECT_CLASS (nbtk_bin_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
st_bin_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
nbtk_bin_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StBin *bin = ST_BIN (gobject);
|
||||
NbtkBin *bin = NBTK_BIN (gobject);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_CHILD:
|
||||
st_bin_set_child (bin, g_value_get_object (value));
|
||||
nbtk_bin_set_child (bin, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_X_ALIGN:
|
||||
st_bin_set_alignment (bin,
|
||||
g_value_get_enum (value),
|
||||
bin->priv->y_align);
|
||||
nbtk_bin_set_alignment (bin,
|
||||
g_value_get_enum (value),
|
||||
bin->priv->y_align);
|
||||
break;
|
||||
|
||||
case PROP_Y_ALIGN:
|
||||
st_bin_set_alignment (bin,
|
||||
bin->priv->x_align,
|
||||
g_value_get_enum (value));
|
||||
nbtk_bin_set_alignment (bin,
|
||||
bin->priv->x_align,
|
||||
g_value_get_enum (value));
|
||||
break;
|
||||
|
||||
case PROP_X_FILL:
|
||||
st_bin_set_fill (bin,
|
||||
g_value_get_boolean (value),
|
||||
bin->priv->y_fill);
|
||||
nbtk_bin_set_fill (bin,
|
||||
g_value_get_boolean (value),
|
||||
bin->priv->y_fill);
|
||||
break;
|
||||
|
||||
case PROP_Y_FILL:
|
||||
st_bin_set_fill (bin,
|
||||
bin->priv->y_fill,
|
||||
g_value_get_boolean (value));
|
||||
nbtk_bin_set_fill (bin,
|
||||
bin->priv->y_fill,
|
||||
g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -404,12 +403,12 @@ st_bin_set_property (GObject *gobject,
|
||||
}
|
||||
|
||||
static void
|
||||
st_bin_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
nbtk_bin_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StBinPrivate *priv = ST_BIN (gobject)->priv;
|
||||
NbtkBinPrivate *priv = NBTK_BIN (gobject)->priv;
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
@ -425,78 +424,70 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
st_bin_class_init (StBinClass *klass)
|
||||
nbtk_bin_class_init (NbtkBinClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
||||
GParamSpec *pspec;
|
||||
|
||||
g_type_class_add_private (klass, sizeof (StBinPrivate));
|
||||
g_type_class_add_private (klass, sizeof (NbtkBinPrivate));
|
||||
|
||||
gobject_class->set_property = st_bin_set_property;
|
||||
gobject_class->get_property = st_bin_get_property;
|
||||
gobject_class->dispose = st_bin_dispose;
|
||||
gobject_class->set_property = nbtk_bin_set_property;
|
||||
gobject_class->get_property = nbtk_bin_get_property;
|
||||
gobject_class->dispose = nbtk_bin_dispose;
|
||||
|
||||
actor_class->get_preferred_width = st_bin_get_preferred_width;
|
||||
actor_class->get_preferred_height = st_bin_get_preferred_height;
|
||||
actor_class->allocate = st_bin_allocate;
|
||||
actor_class->paint = st_bin_paint;
|
||||
actor_class->pick = st_bin_pick;
|
||||
actor_class->get_preferred_width = nbtk_bin_get_preferred_width;
|
||||
actor_class->get_preferred_height = nbtk_bin_get_preferred_height;
|
||||
actor_class->allocate = nbtk_bin_allocate;
|
||||
actor_class->paint = nbtk_bin_paint;
|
||||
actor_class->pick = nbtk_bin_pick;
|
||||
|
||||
/**
|
||||
* StBin:child:
|
||||
* NbtkBin:child:
|
||||
*
|
||||
* The child #ClutterActor of the #StBin container.
|
||||
* The child #ClutterActor of the #NbtkBin container.
|
||||
*/
|
||||
pspec = g_param_spec_object ("child",
|
||||
"Child",
|
||||
"The child of the Bin",
|
||||
CLUTTER_TYPE_ACTOR,
|
||||
ST_PARAM_READWRITE);
|
||||
NBTK_PARAM_READWRITE);
|
||||
g_object_class_install_property (gobject_class, PROP_CHILD, pspec);
|
||||
|
||||
/**
|
||||
* StBin:x-align:
|
||||
* NbtkBin:x-align:
|
||||
*
|
||||
* The horizontal alignment of the #StBin child.
|
||||
* The horizontal alignment of the #NbtkBin child.
|
||||
*/
|
||||
pspec = g_param_spec_enum ("x-align",
|
||||
"X Align",
|
||||
"The horizontal alignment",
|
||||
ST_TYPE_ALIGN,
|
||||
ST_ALIGN_MIDDLE,
|
||||
ST_PARAM_READWRITE);
|
||||
NBTK_TYPE_ALIGNMENT,
|
||||
NBTK_ALIGN_CENTER,
|
||||
NBTK_PARAM_READWRITE);
|
||||
g_object_class_install_property (gobject_class, PROP_X_ALIGN, pspec);
|
||||
|
||||
/**
|
||||
* StBin:y-align:
|
||||
* NbtkBin:y-align:
|
||||
*
|
||||
* The vertical alignment of the #StBin child.
|
||||
* The vertical alignment of the #NbtkBin child.
|
||||
*/
|
||||
pspec = g_param_spec_enum ("y-align",
|
||||
"Y Align",
|
||||
"The vertical alignment",
|
||||
ST_TYPE_ALIGN,
|
||||
ST_ALIGN_MIDDLE,
|
||||
ST_PARAM_READWRITE);
|
||||
NBTK_TYPE_ALIGNMENT,
|
||||
NBTK_ALIGN_CENTER,
|
||||
NBTK_PARAM_READWRITE);
|
||||
g_object_class_install_property (gobject_class, PROP_Y_ALIGN, pspec);
|
||||
|
||||
/**
|
||||
* StBin:x-fill:
|
||||
* NbtkBin:x-fill:
|
||||
*
|
||||
* Whether the child should fill the horizontal allocation
|
||||
*/
|
||||
@ -505,11 +496,11 @@ st_bin_class_init (StBinClass *klass)
|
||||
"Whether the child should fill the "
|
||||
"horizontal allocation",
|
||||
FALSE,
|
||||
ST_PARAM_READWRITE);
|
||||
NBTK_PARAM_READWRITE);
|
||||
g_object_class_install_property (gobject_class, PROP_X_FILL, pspec);
|
||||
|
||||
/**
|
||||
* StBin:y-fill:
|
||||
* NbtkBin:y-fill:
|
||||
*
|
||||
* Whether the child should fill the vertical allocation
|
||||
*/
|
||||
@ -518,35 +509,35 @@ st_bin_class_init (StBinClass *klass)
|
||||
"Whether the child should fill the "
|
||||
"vertical allocation",
|
||||
FALSE,
|
||||
ST_PARAM_READWRITE);
|
||||
NBTK_PARAM_READWRITE);
|
||||
g_object_class_install_property (gobject_class, PROP_Y_FILL, pspec);
|
||||
}
|
||||
|
||||
static void
|
||||
st_bin_init (StBin *bin)
|
||||
nbtk_bin_init (NbtkBin *bin)
|
||||
{
|
||||
bin->priv = ST_BIN_GET_PRIVATE (bin);
|
||||
bin->priv = NBTK_BIN_GET_PRIVATE (bin);
|
||||
|
||||
bin->priv->x_align = ST_ALIGN_MIDDLE;
|
||||
bin->priv->y_align = ST_ALIGN_MIDDLE;
|
||||
bin->priv->x_align = NBTK_ALIGN_CENTER;
|
||||
bin->priv->y_align = NBTK_ALIGN_CENTER;
|
||||
}
|
||||
|
||||
/**
|
||||
* st_bin_new:
|
||||
* nbtk_bin_new:
|
||||
*
|
||||
* Creates a new #StBin, a simple container for one child.
|
||||
* Creates a new #NbtkBin, a simple container for one child.
|
||||
*
|
||||
* Return value: the newly created #StBin actor
|
||||
* Return value: the newly created #NbtkBin actor
|
||||
*/
|
||||
StWidget *
|
||||
st_bin_new (void)
|
||||
NbtkWidget *
|
||||
nbtk_bin_new (void)
|
||||
{
|
||||
return g_object_new (ST_TYPE_BIN, NULL);
|
||||
return g_object_new (NBTK_TYPE_BIN, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_bin_set_child:
|
||||
* @bin: a #StBin
|
||||
* nbtk_bin_set_child:
|
||||
* @bin: a #NbtkBin
|
||||
* @child: a #ClutterActor, or %NULL
|
||||
*
|
||||
* Sets @child as the child of @bin.
|
||||
@ -554,12 +545,12 @@ st_bin_new (void)
|
||||
* If @bin already has a child, the previous child is removed.
|
||||
*/
|
||||
void
|
||||
st_bin_set_child (StBin *bin,
|
||||
ClutterActor *child)
|
||||
nbtk_bin_set_child (NbtkBin *bin,
|
||||
ClutterActor *child)
|
||||
{
|
||||
StBinPrivate *priv;
|
||||
NbtkBinPrivate *priv;
|
||||
|
||||
g_return_if_fail (ST_IS_BIN (bin));
|
||||
g_return_if_fail (NBTK_IS_BIN (bin));
|
||||
g_return_if_fail (child == NULL || CLUTTER_IS_ACTOR (child));
|
||||
|
||||
priv = bin->priv;
|
||||
@ -595,39 +586,39 @@ st_bin_set_child (StBin *bin,
|
||||
}
|
||||
|
||||
/**
|
||||
* st_bin_get_child:
|
||||
* @bin: a #StBin
|
||||
* nbtk_bin_get_child:
|
||||
* @bin: a #NbtkBin
|
||||
*
|
||||
* Retrieves a pointer to the child of @bin.
|
||||
*
|
||||
* Return value: (transfer none): a #ClutterActor, or %NULL
|
||||
*/
|
||||
ClutterActor *
|
||||
st_bin_get_child (StBin *bin)
|
||||
nbtk_bin_get_child (NbtkBin *bin)
|
||||
{
|
||||
g_return_val_if_fail (ST_IS_BIN (bin), NULL);
|
||||
g_return_val_if_fail (NBTK_IS_BIN (bin), NULL);
|
||||
|
||||
return bin->priv->child;
|
||||
}
|
||||
|
||||
/**
|
||||
* st_bin_set_alignment:
|
||||
* @bin: a #StBin
|
||||
* nbtk_bin_set_alignment:
|
||||
* @bin: a #NbtkBin
|
||||
* @x_align: horizontal alignment
|
||||
* @y_align: vertical alignment
|
||||
*
|
||||
* Sets the horizontal and vertical alignment of the child
|
||||
* inside a #StBin.
|
||||
* inside a #NbtkBin.
|
||||
*/
|
||||
void
|
||||
st_bin_set_alignment (StBin *bin,
|
||||
StAlign x_align,
|
||||
StAlign y_align)
|
||||
nbtk_bin_set_alignment (NbtkBin *bin,
|
||||
NbtkAlignment x_align,
|
||||
NbtkAlignment y_align)
|
||||
{
|
||||
StBinPrivate *priv;
|
||||
NbtkBinPrivate *priv;
|
||||
gboolean changed = FALSE;
|
||||
|
||||
g_return_if_fail (ST_IS_BIN (bin));
|
||||
g_return_if_fail (NBTK_IS_BIN (bin));
|
||||
|
||||
priv = bin->priv;
|
||||
|
||||
@ -654,22 +645,22 @@ st_bin_set_alignment (StBin *bin,
|
||||
}
|
||||
|
||||
/**
|
||||
* st_bin_get_alignment:
|
||||
* @bin: a #StBin
|
||||
* nbtk_bin_get_alignment:
|
||||
* @bin: a #NbtkBin
|
||||
* @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().
|
||||
* inside a #NbtkBin, as set by nbtk_bin_set_alignment().
|
||||
*/
|
||||
void
|
||||
st_bin_get_alignment (StBin *bin,
|
||||
StAlign *x_align,
|
||||
StAlign *y_align)
|
||||
nbtk_bin_get_alignment (NbtkBin *bin,
|
||||
NbtkAlignment *x_align,
|
||||
NbtkAlignment *y_align)
|
||||
{
|
||||
StBinPrivate *priv;
|
||||
NbtkBinPrivate *priv;
|
||||
|
||||
g_return_if_fail (ST_IS_BIN (bin));
|
||||
g_return_if_fail (NBTK_IS_BIN (bin));
|
||||
|
||||
priv = bin->priv;
|
||||
|
||||
@ -681,8 +672,8 @@ st_bin_get_alignment (StBin *bin,
|
||||
}
|
||||
|
||||
/**
|
||||
* st_bin_set_fill:
|
||||
* @bin: a #StBin
|
||||
* nbtk_bin_set_fill:
|
||||
* @bin: a #NbtkBin
|
||||
* @x_fill: %TRUE if the child should fill horizontally the @bin
|
||||
* @y_fill: %TRUE if the child should fill vertically the @bin
|
||||
*
|
||||
@ -690,14 +681,14 @@ st_bin_get_alignment (StBin *bin,
|
||||
* and/or vertical allocation of the parent
|
||||
*/
|
||||
void
|
||||
st_bin_set_fill (StBin *bin,
|
||||
gboolean x_fill,
|
||||
gboolean y_fill)
|
||||
nbtk_bin_set_fill (NbtkBin *bin,
|
||||
gboolean x_fill,
|
||||
gboolean y_fill)
|
||||
{
|
||||
StBinPrivate *priv;
|
||||
NbtkBinPrivate *priv;
|
||||
gboolean changed = FALSE;
|
||||
|
||||
g_return_if_fail (ST_IS_BIN (bin));
|
||||
g_return_if_fail (NBTK_IS_BIN (bin));
|
||||
|
||||
priv = bin->priv;
|
||||
|
||||
@ -726,19 +717,19 @@ st_bin_set_fill (StBin *bin,
|
||||
}
|
||||
|
||||
/**
|
||||
* st_bin_get_fill:
|
||||
* @bin: a #StBin
|
||||
* nbtk_bin_get_fill:
|
||||
* @bin: a #NbtkBin
|
||||
* @x_fill: (out): return location for the horizontal fill, or %NULL
|
||||
* @y_fill: (out): return location for the vertical fill, or %NULL
|
||||
*
|
||||
* Retrieves the horizontal and vertical fill settings
|
||||
*/
|
||||
void
|
||||
st_bin_get_fill (StBin *bin,
|
||||
gboolean *x_fill,
|
||||
gboolean *y_fill)
|
||||
nbtk_bin_get_fill (NbtkBin *bin,
|
||||
gboolean *x_fill,
|
||||
gboolean *y_fill)
|
||||
{
|
||||
g_return_if_fail (ST_IS_BIN (bin));
|
||||
g_return_if_fail (NBTK_IS_BIN (bin));
|
||||
|
||||
if (x_fill)
|
||||
*x_fill = bin->priv->x_fill;
|
92
src/nbtk/nbtk-bin.h
Normal file
92
src/nbtk/nbtk-bin.h
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* nbtk-bin.h: Basic container actor
|
||||
*
|
||||
* Copyright 2009, 2008 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Written by: Emmanuele Bassi <ebassi@linux.intel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(NBTK_H_INSIDE) && !defined(NBTK_COMPILATION)
|
||||
#error "Only <nbtk/nbtk.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef __NBTK_BIN_H__
|
||||
#define __NBTK_BIN_H__
|
||||
|
||||
#include <nbtk/nbtk-types.h>
|
||||
#include <nbtk/nbtk-widget.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NBTK_TYPE_BIN (nbtk_bin_get_type ())
|
||||
#define NBTK_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NBTK_TYPE_BIN, NbtkBin))
|
||||
#define NBTK_IS_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NBTK_TYPE_BIN))
|
||||
#define NBTK_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NBTK_TYPE_BIN, NbtkBinClass))
|
||||
#define NBTK_IS_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NBTK_TYPE_BIN))
|
||||
#define NBTK_BIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NBTK_TYPE_BIN, NbtkBinClass))
|
||||
|
||||
typedef struct _NbtkBin NbtkBin;
|
||||
typedef struct _NbtkBinPrivate NbtkBinPrivate;
|
||||
typedef struct _NbtkBinClass NbtkBinClass;
|
||||
|
||||
/**
|
||||
* NbtkBin:
|
||||
*
|
||||
* The #NbtkBin struct contains only private data
|
||||
*/
|
||||
struct _NbtkBin
|
||||
{
|
||||
/*< private >*/
|
||||
NbtkWidget parent_instance;
|
||||
|
||||
NbtkBinPrivate *priv;
|
||||
};
|
||||
|
||||
/**
|
||||
* NbtkBinClass:
|
||||
*
|
||||
* The #NbtkBinClass struct contains only private data
|
||||
*/
|
||||
struct _NbtkBinClass
|
||||
{
|
||||
/*< private >*/
|
||||
NbtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
GType nbtk_bin_get_type (void) G_GNUC_CONST;
|
||||
|
||||
NbtkWidget *nbtk_bin_new (void);
|
||||
void nbtk_bin_set_child (NbtkBin *bin,
|
||||
ClutterActor *child);
|
||||
ClutterActor *nbtk_bin_get_child (NbtkBin *bin);
|
||||
void nbtk_bin_set_alignment (NbtkBin *bin,
|
||||
NbtkAlignment x_align,
|
||||
NbtkAlignment y_align);
|
||||
void nbtk_bin_get_alignment (NbtkBin *bin,
|
||||
NbtkAlignment *x_align,
|
||||
NbtkAlignment *y_align);
|
||||
void nbtk_bin_set_fill (NbtkBin *bin,
|
||||
gboolean x_fill,
|
||||
gboolean y_fill);
|
||||
void nbtk_bin_get_fill (NbtkBin *bin,
|
||||
gboolean *x_fill,
|
||||
gboolean *y_fill);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NBTK_BIN_H__ */
|
@ -1,6 +1,5 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-box-layout-child.c: box layout child actor
|
||||
* nbtk-box-layout-child.c: box layout child actor
|
||||
*
|
||||
* Copyright 2009 Intel Corporation
|
||||
*
|
||||
@ -20,21 +19,13 @@
|
||||
* Written by: Thomas Wood <thomas.wood@intel.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:st-box-layout-child
|
||||
* @short_description: meta data associated with a #StBoxLayout child.
|
||||
*
|
||||
* #StBoxLayoutChild is a #ClutterChildMeta implementation that stores the
|
||||
* child properties for children inside a #StBoxLayout.
|
||||
*/
|
||||
#include "nbtk-box-layout-child.h"
|
||||
#include "nbtk-private.h"
|
||||
|
||||
#include "st-box-layout-child.h"
|
||||
#include "st-private.h"
|
||||
|
||||
G_DEFINE_TYPE (StBoxLayoutChild, st_box_layout_child, CLUTTER_TYPE_CHILD_META)
|
||||
G_DEFINE_TYPE (NbtkBoxLayoutChild, nbtk_box_layout_child, CLUTTER_TYPE_CHILD_META)
|
||||
|
||||
#define BOX_LAYOUT_CHILD_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), ST_TYPE_BOX_LAYOUT_CHILD, StBoxLayoutChildPrivate))
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), NBTK_TYPE_BOX_LAYOUT_CHILD, NbtkBoxLayoutChildPrivate))
|
||||
|
||||
|
||||
enum
|
||||
@ -49,12 +40,10 @@ enum
|
||||
};
|
||||
|
||||
static void
|
||||
st_box_layout_child_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
nbtk_box_layout_child_get_property (GObject *object, guint property_id,
|
||||
GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
StBoxLayoutChild *child = ST_BOX_LAYOUT_CHILD (object);
|
||||
NbtkBoxLayoutChild *child = NBTK_BOX_LAYOUT_CHILD (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
@ -80,13 +69,11 @@ st_box_layout_child_get_property (GObject *object,
|
||||
}
|
||||
|
||||
static void
|
||||
st_box_layout_child_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
nbtk_box_layout_child_set_property (GObject *object, guint property_id,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
StBoxLayoutChild *child = ST_BOX_LAYOUT_CHILD (object);
|
||||
StBoxLayout *box = ST_BOX_LAYOUT (CLUTTER_CHILD_META (object)->container);
|
||||
NbtkBoxLayoutChild *child = NBTK_BOX_LAYOUT_CHILD (object);
|
||||
NbtkBoxLayout *box = NBTK_BOX_LAYOUT (CLUTTER_CHILD_META (object)->container);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
@ -114,33 +101,33 @@ st_box_layout_child_set_property (GObject *object,
|
||||
}
|
||||
|
||||
static void
|
||||
st_box_layout_child_dispose (GObject *object)
|
||||
nbtk_box_layout_child_dispose (GObject *object)
|
||||
{
|
||||
G_OBJECT_CLASS (st_box_layout_child_parent_class)->dispose (object);
|
||||
G_OBJECT_CLASS (nbtk_box_layout_child_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
st_box_layout_child_finalize (GObject *object)
|
||||
nbtk_box_layout_child_finalize (GObject *object)
|
||||
{
|
||||
G_OBJECT_CLASS (st_box_layout_child_parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (nbtk_box_layout_child_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
st_box_layout_child_class_init (StBoxLayoutChildClass *klass)
|
||||
nbtk_box_layout_child_class_init (NbtkBoxLayoutChildClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GParamSpec *pspec;
|
||||
|
||||
object_class->get_property = st_box_layout_child_get_property;
|
||||
object_class->set_property = st_box_layout_child_set_property;
|
||||
object_class->dispose = st_box_layout_child_dispose;
|
||||
object_class->finalize = st_box_layout_child_finalize;
|
||||
object_class->get_property = nbtk_box_layout_child_get_property;
|
||||
object_class->set_property = nbtk_box_layout_child_set_property;
|
||||
object_class->dispose = nbtk_box_layout_child_dispose;
|
||||
object_class->finalize = nbtk_box_layout_child_finalize;
|
||||
|
||||
|
||||
pspec = g_param_spec_boolean ("expand", "Expand",
|
||||
"Allocate the child extra space",
|
||||
FALSE,
|
||||
ST_PARAM_READWRITE);
|
||||
NBTK_PARAM_READWRITE);
|
||||
g_object_class_install_property (object_class, PROP_EXPAND, pspec);
|
||||
|
||||
pspec = g_param_spec_boolean ("x-fill", "x-fill",
|
||||
@ -148,7 +135,7 @@ st_box_layout_child_class_init (StBoxLayoutChildClass *klass)
|
||||
"when the container is allocating spare space "
|
||||
"on the horizontal axis",
|
||||
TRUE,
|
||||
ST_PARAM_READWRITE);
|
||||
NBTK_PARAM_READWRITE);
|
||||
g_object_class_install_property (object_class, PROP_X_FILL, pspec);
|
||||
|
||||
pspec = g_param_spec_boolean ("y-fill", "y-fill",
|
||||
@ -156,35 +143,34 @@ st_box_layout_child_class_init (StBoxLayoutChildClass *klass)
|
||||
"when the container is allocating spare space "
|
||||
"on the vertical axis",
|
||||
TRUE,
|
||||
ST_PARAM_READWRITE);
|
||||
NBTK_PARAM_READWRITE);
|
||||
g_object_class_install_property (object_class, PROP_Y_FILL, pspec);
|
||||
|
||||
pspec = g_param_spec_enum ("x-align",
|
||||
"X Alignment",
|
||||
"X alignment of the widget within the cell",
|
||||
ST_TYPE_ALIGN,
|
||||
ST_ALIGN_MIDDLE,
|
||||
ST_PARAM_READWRITE);
|
||||
NBTK_TYPE_ALIGN,
|
||||
NBTK_ALIGN_MIDDLE,
|
||||
NBTK_PARAM_READWRITE);
|
||||
g_object_class_install_property (object_class, PROP_X_ALIGN, pspec);
|
||||
|
||||
pspec = g_param_spec_enum ("y-align",
|
||||
"Y Alignment",
|
||||
"Y alignment of the widget within the cell",
|
||||
ST_TYPE_ALIGN,
|
||||
ST_ALIGN_MIDDLE,
|
||||
ST_PARAM_READWRITE);
|
||||
NBTK_TYPE_ALIGN,
|
||||
NBTK_ALIGN_MIDDLE,
|
||||
NBTK_PARAM_READWRITE);
|
||||
g_object_class_install_property (object_class, PROP_Y_ALIGN, pspec);
|
||||
}
|
||||
|
||||
static void
|
||||
st_box_layout_child_init (StBoxLayoutChild *self)
|
||||
nbtk_box_layout_child_init (NbtkBoxLayoutChild *self)
|
||||
{
|
||||
self->expand = FALSE;
|
||||
|
||||
self->x_fill = TRUE;
|
||||
self->y_fill = TRUE;
|
||||
|
||||
self->x_align = ST_ALIGN_MIDDLE;
|
||||
self->y_align = ST_ALIGN_MIDDLE;
|
||||
self->x_align = NBTK_ALIGN_CENTER;
|
||||
self->y_align = NBTK_ALIGN_CENTER;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-box-layout-child.h: box layout child actor
|
||||
* nbtk-box-layout-child.h: box layout child actor
|
||||
*
|
||||
* Copyright 2009 Intel Corporation
|
||||
*
|
||||
@ -20,48 +19,48 @@
|
||||
* Written by: Thomas Wood <thomas.wood@intel.com>
|
||||
*/
|
||||
|
||||
#ifndef _ST_BOX_LAYOUT_CHILD_H
|
||||
#define _ST_BOX_LAYOUT_CHILD_H
|
||||
#ifndef _NBTK_BOX_LAYOUT_CHILD_H
|
||||
#define _NBTK_BOX_LAYOUT_CHILD_H
|
||||
|
||||
#include <clutter/clutter.h>
|
||||
#include "st-enum-types.h"
|
||||
#include "st-box-layout.h"
|
||||
#include "nbtk-enum-types.h"
|
||||
#include "nbtk-box-layout.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define ST_TYPE_BOX_LAYOUT_CHILD st_box_layout_child_get_type()
|
||||
#define NBTK_TYPE_BOX_LAYOUT_CHILD nbtk_box_layout_child_get_type()
|
||||
|
||||
#define ST_BOX_LAYOUT_CHILD(obj) \
|
||||
#define NBTK_BOX_LAYOUT_CHILD(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
||||
ST_TYPE_BOX_LAYOUT_CHILD, StBoxLayoutChild))
|
||||
NBTK_TYPE_BOX_LAYOUT_CHILD, NbtkBoxLayoutChild))
|
||||
|
||||
#define ST_BOX_LAYOUT_CHILD_CLASS(klass) \
|
||||
#define NBTK_BOX_LAYOUT_CHILD_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), \
|
||||
ST_TYPE_BOX_LAYOUT_CHILD, StBoxLayoutChildClass))
|
||||
NBTK_TYPE_BOX_LAYOUT_CHILD, NbtkBoxLayoutChildClass))
|
||||
|
||||
#define ST_IS_BOX_LAYOUT_CHILD(obj) \
|
||||
#define NBTK_IS_BOX_LAYOUT_CHILD(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
|
||||
ST_TYPE_BOX_LAYOUT_CHILD))
|
||||
NBTK_TYPE_BOX_LAYOUT_CHILD))
|
||||
|
||||
#define ST_IS_BOX_LAYOUT_CHILD_CLASS(klass) \
|
||||
#define NBTK_IS_BOX_LAYOUT_CHILD_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
|
||||
ST_TYPE_BOX_LAYOUT_CHILD))
|
||||
NBTK_TYPE_BOX_LAYOUT_CHILD))
|
||||
|
||||
#define ST_BOX_LAYOUT_CHILD_GET_CLASS(obj) \
|
||||
#define NBTK_BOX_LAYOUT_CHILD_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
|
||||
ST_TYPE_BOX_LAYOUT_CHILD, StBoxLayoutChildClass))
|
||||
NBTK_TYPE_BOX_LAYOUT_CHILD, NbtkBoxLayoutChildClass))
|
||||
|
||||
typedef struct _StBoxLayoutChild StBoxLayoutChild;
|
||||
typedef struct _StBoxLayoutChildClass StBoxLayoutChildClass;
|
||||
typedef struct _StBoxLayoutChildPrivate StBoxLayoutChildPrivate;
|
||||
typedef struct _NbtkBoxLayoutChild NbtkBoxLayoutChild;
|
||||
typedef struct _NbtkBoxLayoutChildClass NbtkBoxLayoutChildClass;
|
||||
typedef struct _NbtkBoxLayoutChildPrivate NbtkBoxLayoutChildPrivate;
|
||||
|
||||
/**
|
||||
* StBoxLayoutChild:
|
||||
* NbtkBoxLayoutChild:
|
||||
*
|
||||
* The contents of this structure are private and should only be accessed
|
||||
* through the public API.
|
||||
*/
|
||||
struct _StBoxLayoutChild
|
||||
struct _NbtkBoxLayoutChild
|
||||
{
|
||||
/*< private >*/
|
||||
ClutterChildMeta parent;
|
||||
@ -69,17 +68,17 @@ struct _StBoxLayoutChild
|
||||
gboolean expand;
|
||||
gboolean x_fill : 1;
|
||||
gboolean y_fill : 1;
|
||||
StAlign x_align;
|
||||
StAlign y_align;
|
||||
NbtkAlign x_align;
|
||||
NbtkAlign y_align;
|
||||
};
|
||||
|
||||
struct _StBoxLayoutChildClass
|
||||
struct _NbtkBoxLayoutChildClass
|
||||
{
|
||||
ClutterChildMetaClass parent_class;
|
||||
};
|
||||
|
||||
GType st_box_layout_child_get_type (void);
|
||||
GType nbtk_box_layout_child_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _ST_BOX_LAYOUT_CHILD_H */
|
||||
#endif /* _NBTK_BOX_LAYOUT_CHILD_H */
|
@ -1,6 +1,5 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-box-layout.h: box layout actor
|
||||
* nbtk-box-layout.h: box layout actor
|
||||
*
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
@ -21,81 +20,70 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:st-box-layout
|
||||
* @short_description: a layout container arranging children in a single line
|
||||
*
|
||||
* The #StBoxLayout arranges its children along a single line, where each
|
||||
* child can be allocated either its preferred size or larger if the expand
|
||||
* option is set. If the fill option is set, the actor will be allocated more
|
||||
* than its requested size. If the fill option is not set, but the expand option
|
||||
* is enabled, then the position of the actor within the available space can
|
||||
* be determined by the alignment child property.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "st-box-layout.h"
|
||||
#include "nbtk-box-layout.h"
|
||||
|
||||
#include "st-private.h"
|
||||
#include "st-scrollable.h"
|
||||
#include "st-box-layout-child.h"
|
||||
#include "nbtk-private.h"
|
||||
#include "nbtk-scrollable.h"
|
||||
#include "nbtk-box-layout-child.h"
|
||||
|
||||
|
||||
|
||||
static void st_box_container_iface_init (ClutterContainerIface *iface);
|
||||
static void st_box_scrollable_interface_init (StScrollableInterface *iface);
|
||||
static void nbtk_box_container_iface_init (ClutterContainerIface *iface);
|
||||
static void nbtk_box_scrollable_interface_init (NbtkScrollableInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (StBoxLayout, st_box_layout, ST_TYPE_WIDGET,
|
||||
G_DEFINE_TYPE_WITH_CODE (NbtkBoxLayout, nbtk_box_layout, NBTK_TYPE_WIDGET,
|
||||
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_CONTAINER,
|
||||
st_box_container_iface_init)
|
||||
G_IMPLEMENT_INTERFACE (ST_TYPE_SCROLLABLE,
|
||||
st_box_scrollable_interface_init));
|
||||
nbtk_box_container_iface_init)
|
||||
G_IMPLEMENT_INTERFACE (NBTK_TYPE_SCROLLABLE,
|
||||
nbtk_box_scrollable_interface_init));
|
||||
|
||||
#define BOX_LAYOUT_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), ST_TYPE_BOX_LAYOUT, StBoxLayoutPrivate))
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), NBTK_TYPE_BOX_LAYOUT, NbtkBoxLayoutPrivate))
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
|
||||
PROP_VERTICAL,
|
||||
PROP_PACK_START,
|
||||
PROP_SPACING,
|
||||
|
||||
PROP_HADJUST,
|
||||
PROP_VADJUST
|
||||
};
|
||||
|
||||
struct _StBoxLayoutPrivate
|
||||
struct _NbtkBoxLayoutPrivate
|
||||
{
|
||||
GList *children;
|
||||
GList *children;
|
||||
|
||||
guint spacing;
|
||||
guint spacing;
|
||||
|
||||
guint is_vertical : 1;
|
||||
guint is_pack_start : 1;
|
||||
guint is_vertical : 1;
|
||||
guint is_pack_start : 1;
|
||||
|
||||
StAdjustment *hadjustment;
|
||||
StAdjustment *vadjustment;
|
||||
NbtkAdjustment *hadjustment;
|
||||
NbtkAdjustment *vadjustment;
|
||||
};
|
||||
|
||||
/*
|
||||
* StScrollable Interface Implementation
|
||||
* NbtkScrollable Interface Implementation
|
||||
*/
|
||||
static void
|
||||
adjustment_value_notify_cb (StAdjustment *adjustment,
|
||||
GParamSpec *pspec,
|
||||
StBoxLayout *box)
|
||||
adjustment_value_notify_cb (NbtkAdjustment *adjustment,
|
||||
GParamSpec *pspec,
|
||||
NbtkBoxLayout *box)
|
||||
{
|
||||
clutter_actor_queue_redraw (CLUTTER_ACTOR (box));
|
||||
}
|
||||
|
||||
static void
|
||||
scrollable_set_adjustments (StScrollable *scrollable,
|
||||
StAdjustment *hadjustment,
|
||||
StAdjustment *vadjustment)
|
||||
scrollable_set_adjustments (NbtkScrollable *scrollable,
|
||||
NbtkAdjustment *hadjustment,
|
||||
NbtkAdjustment *vadjustment)
|
||||
{
|
||||
StBoxLayoutPrivate *priv = ST_BOX_LAYOUT (scrollable)->priv;
|
||||
NbtkBoxLayoutPrivate *priv = NBTK_BOX_LAYOUT (scrollable)->priv;
|
||||
|
||||
if (hadjustment != priv->hadjustment)
|
||||
{
|
||||
@ -141,14 +129,14 @@ scrollable_set_adjustments (StScrollable *scrollable,
|
||||
}
|
||||
|
||||
static void
|
||||
scrollable_get_adjustments (StScrollable *scrollable,
|
||||
StAdjustment **hadjustment,
|
||||
StAdjustment **vadjustment)
|
||||
scrollable_get_adjustments (NbtkScrollable *scrollable,
|
||||
NbtkAdjustment **hadjustment,
|
||||
NbtkAdjustment **vadjustment)
|
||||
{
|
||||
StBoxLayoutPrivate *priv;
|
||||
NbtkBoxLayoutPrivate *priv;
|
||||
ClutterActor *actor, *stage;
|
||||
|
||||
priv = (ST_BOX_LAYOUT (scrollable))->priv;
|
||||
priv = (NBTK_BOX_LAYOUT (scrollable))->priv;
|
||||
|
||||
actor = CLUTTER_ACTOR (scrollable);
|
||||
stage = clutter_actor_get_stage (actor);
|
||||
@ -159,7 +147,7 @@ scrollable_get_adjustments (StScrollable *scrollable,
|
||||
*hadjustment = priv->hadjustment;
|
||||
else
|
||||
{
|
||||
StAdjustment *adjustment;
|
||||
NbtkAdjustment *adjustment;
|
||||
gdouble width, stage_width, increment;
|
||||
|
||||
if (stage)
|
||||
@ -173,12 +161,12 @@ scrollable_get_adjustments (StScrollable *scrollable,
|
||||
width = increment = 1.0;
|
||||
}
|
||||
|
||||
adjustment = st_adjustment_new (0,
|
||||
0,
|
||||
width,
|
||||
1.0,
|
||||
increment,
|
||||
increment);
|
||||
adjustment = nbtk_adjustment_new (0,
|
||||
0,
|
||||
width,
|
||||
1.0,
|
||||
increment,
|
||||
increment);
|
||||
|
||||
scrollable_set_adjustments (scrollable,
|
||||
adjustment,
|
||||
@ -194,7 +182,7 @@ scrollable_get_adjustments (StScrollable *scrollable,
|
||||
*vadjustment = priv->vadjustment;
|
||||
else
|
||||
{
|
||||
StAdjustment *adjustment;
|
||||
NbtkAdjustment *adjustment;
|
||||
gdouble height, stage_height, increment;
|
||||
|
||||
if (stage)
|
||||
@ -208,12 +196,12 @@ scrollable_get_adjustments (StScrollable *scrollable,
|
||||
height = increment = 1.0;
|
||||
}
|
||||
|
||||
adjustment = st_adjustment_new (0,
|
||||
0,
|
||||
height,
|
||||
1.0,
|
||||
increment,
|
||||
increment);
|
||||
adjustment = nbtk_adjustment_new (0,
|
||||
0,
|
||||
height,
|
||||
1.0,
|
||||
increment,
|
||||
increment);
|
||||
|
||||
scrollable_set_adjustments (scrollable,
|
||||
priv->hadjustment,
|
||||
@ -227,7 +215,7 @@ scrollable_get_adjustments (StScrollable *scrollable,
|
||||
|
||||
|
||||
static void
|
||||
st_box_scrollable_interface_init (StScrollableInterface *iface)
|
||||
nbtk_box_scrollable_interface_init (NbtkScrollableInterface *iface)
|
||||
{
|
||||
iface->set_adjustments = scrollable_set_adjustments;
|
||||
iface->get_adjustments = scrollable_get_adjustments;
|
||||
@ -237,10 +225,10 @@ st_box_scrollable_interface_init (StScrollableInterface *iface)
|
||||
* ClutterContainer Implementation
|
||||
*/
|
||||
static void
|
||||
st_box_container_add_actor (ClutterContainer *container,
|
||||
ClutterActor *actor)
|
||||
nbtk_box_container_add_actor (ClutterContainer *container,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
StBoxLayoutPrivate *priv = ST_BOX_LAYOUT (container)->priv;
|
||||
NbtkBoxLayoutPrivate *priv = NBTK_BOX_LAYOUT (container)->priv;
|
||||
|
||||
clutter_actor_set_parent (actor, CLUTTER_ACTOR (container));
|
||||
|
||||
@ -250,10 +238,10 @@ st_box_container_add_actor (ClutterContainer *container,
|
||||
}
|
||||
|
||||
static void
|
||||
st_box_container_remove_actor (ClutterContainer *container,
|
||||
ClutterActor *actor)
|
||||
nbtk_box_container_remove_actor (ClutterContainer *container,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
StBoxLayoutPrivate *priv = ST_BOX_LAYOUT (container)->priv;
|
||||
NbtkBoxLayoutPrivate *priv = NBTK_BOX_LAYOUT (container)->priv;
|
||||
|
||||
GList *item = NULL;
|
||||
|
||||
@ -280,62 +268,62 @@ st_box_container_remove_actor (ClutterContainer *container,
|
||||
}
|
||||
|
||||
static void
|
||||
st_box_container_foreach (ClutterContainer *container,
|
||||
ClutterCallback callback,
|
||||
gpointer callback_data)
|
||||
nbtk_box_container_foreach (ClutterContainer *container,
|
||||
ClutterCallback callback,
|
||||
gpointer callback_data)
|
||||
{
|
||||
StBoxLayoutPrivate *priv = ST_BOX_LAYOUT (container)->priv;
|
||||
NbtkBoxLayoutPrivate *priv = NBTK_BOX_LAYOUT (container)->priv;
|
||||
|
||||
g_list_foreach (priv->children, (GFunc) callback, callback_data);
|
||||
}
|
||||
|
||||
static void
|
||||
st_box_container_lower (ClutterContainer *container,
|
||||
ClutterActor *actor,
|
||||
ClutterActor *sibling)
|
||||
nbtk_box_container_lower (ClutterContainer *container,
|
||||
ClutterActor *actor,
|
||||
ClutterActor *sibling)
|
||||
{
|
||||
/* XXX: not yet implemented */
|
||||
g_warning ("%s() not yet implemented", __FUNCTION__);
|
||||
}
|
||||
|
||||
static void
|
||||
st_box_container_raise (ClutterContainer *container,
|
||||
ClutterActor *actor,
|
||||
ClutterActor *sibling)
|
||||
nbtk_box_container_raise (ClutterContainer *container,
|
||||
ClutterActor *actor,
|
||||
ClutterActor *sibling)
|
||||
{
|
||||
/* XXX: not yet implemented */
|
||||
g_warning ("%s() not yet implemented", __FUNCTION__);
|
||||
}
|
||||
|
||||
static void
|
||||
st_box_container_sort_depth_order (ClutterContainer *container)
|
||||
nbtk_box_container_sort_depth_order (ClutterContainer *container)
|
||||
{
|
||||
/* XXX: not yet implemented */
|
||||
g_warning ("%s() not yet implemented", __FUNCTION__);
|
||||
}
|
||||
|
||||
static void
|
||||
st_box_container_iface_init (ClutterContainerIface *iface)
|
||||
nbtk_box_container_iface_init (ClutterContainerIface *iface)
|
||||
{
|
||||
iface->add = st_box_container_add_actor;
|
||||
iface->remove = st_box_container_remove_actor;
|
||||
iface->foreach = st_box_container_foreach;
|
||||
iface->lower = st_box_container_lower;
|
||||
iface->raise = st_box_container_raise;
|
||||
iface->sort_depth_order = st_box_container_sort_depth_order;
|
||||
iface->add = nbtk_box_container_add_actor;
|
||||
iface->remove = nbtk_box_container_remove_actor;
|
||||
iface->foreach = nbtk_box_container_foreach;
|
||||
iface->lower = nbtk_box_container_lower;
|
||||
iface->raise = nbtk_box_container_raise;
|
||||
iface->sort_depth_order = nbtk_box_container_sort_depth_order;
|
||||
|
||||
iface->child_meta_type = ST_TYPE_BOX_LAYOUT_CHILD;
|
||||
iface->child_meta_type = NBTK_TYPE_BOX_LAYOUT_CHILD;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
st_box_layout_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
nbtk_box_layout_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StBoxLayoutPrivate *priv = ST_BOX_LAYOUT (object)->priv;
|
||||
StAdjustment *adjustment;
|
||||
NbtkBoxLayoutPrivate *priv = NBTK_BOX_LAYOUT (object)->priv;
|
||||
NbtkAdjustment *adjustment;
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
@ -347,13 +335,17 @@ st_box_layout_get_property (GObject *object,
|
||||
g_value_set_boolean (value, priv->is_pack_start);
|
||||
break;
|
||||
|
||||
case PROP_HADJUST:
|
||||
scrollable_get_adjustments (ST_SCROLLABLE (object), &adjustment, NULL);
|
||||
case PROP_SPACING:
|
||||
g_value_set_uint (value, priv->spacing);
|
||||
break;
|
||||
|
||||
case PROP_HADJUST :
|
||||
scrollable_get_adjustments (NBTK_SCROLLABLE (object), &adjustment, NULL);
|
||||
g_value_set_object (value, adjustment);
|
||||
break;
|
||||
|
||||
case PROP_VADJUST:
|
||||
scrollable_get_adjustments (ST_SCROLLABLE (object), NULL, &adjustment);
|
||||
case PROP_VADJUST :
|
||||
scrollable_get_adjustments (NBTK_SCROLLABLE (object), NULL, &adjustment);
|
||||
g_value_set_object (value, adjustment);
|
||||
break;
|
||||
|
||||
@ -363,31 +355,33 @@ st_box_layout_get_property (GObject *object,
|
||||
}
|
||||
|
||||
static void
|
||||
st_box_layout_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
nbtk_box_layout_set_property (GObject *object, guint property_id,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
StBoxLayout *box = ST_BOX_LAYOUT (object);
|
||||
NbtkBoxLayout *box = NBTK_BOX_LAYOUT (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_VERTICAL:
|
||||
st_box_layout_set_vertical (box, g_value_get_boolean (value));
|
||||
nbtk_box_layout_set_vertical (box, g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
case PROP_PACK_START:
|
||||
st_box_layout_set_pack_start (box, g_value_get_boolean (value));
|
||||
nbtk_box_layout_set_pack_start (box, g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
case PROP_HADJUST:
|
||||
scrollable_set_adjustments (ST_SCROLLABLE (object),
|
||||
case PROP_SPACING:
|
||||
nbtk_box_layout_set_spacing (box, g_value_get_uint (value));
|
||||
break;
|
||||
|
||||
case PROP_HADJUST :
|
||||
scrollable_set_adjustments (NBTK_SCROLLABLE (object),
|
||||
g_value_get_object (value),
|
||||
box->priv->vadjustment);
|
||||
break;
|
||||
|
||||
case PROP_VADJUST:
|
||||
scrollable_set_adjustments (ST_SCROLLABLE (object),
|
||||
case PROP_VADJUST :
|
||||
scrollable_set_adjustments (NBTK_SCROLLABLE (object),
|
||||
box->priv->hadjustment,
|
||||
g_value_get_object (value));
|
||||
break;
|
||||
@ -398,9 +392,9 @@ st_box_layout_set_property (GObject *object,
|
||||
}
|
||||
|
||||
static void
|
||||
st_box_layout_dispose (GObject *object)
|
||||
nbtk_box_layout_dispose (GObject *object)
|
||||
{
|
||||
StBoxLayoutPrivate *priv = ST_BOX_LAYOUT (object)->priv;
|
||||
NbtkBoxLayoutPrivate *priv = NBTK_BOX_LAYOUT (object)->priv;
|
||||
|
||||
while (priv->children)
|
||||
{
|
||||
@ -421,16 +415,16 @@ st_box_layout_dispose (GObject *object)
|
||||
priv->vadjustment = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (st_box_layout_parent_class)->dispose (object);
|
||||
G_OBJECT_CLASS (nbtk_box_layout_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
get_content_preferred_width (StBoxLayout *self,
|
||||
gfloat for_height,
|
||||
gfloat *min_width_p,
|
||||
gfloat *natural_width_p)
|
||||
get_content_preferred_width (NbtkBoxLayout *self,
|
||||
gfloat for_height,
|
||||
gfloat *min_width_p,
|
||||
gfloat *natural_width_p)
|
||||
{
|
||||
StBoxLayoutPrivate *priv = self->priv;
|
||||
NbtkBoxLayoutPrivate *priv = self->priv;
|
||||
gint n_children = 0;
|
||||
gfloat min_width, natural_width;
|
||||
GList *l;
|
||||
@ -478,29 +472,29 @@ get_content_preferred_width (StBoxLayout *self,
|
||||
}
|
||||
|
||||
static void
|
||||
st_box_layout_get_preferred_width (ClutterActor *actor,
|
||||
gfloat for_height,
|
||||
gfloat *min_width_p,
|
||||
gfloat *natural_width_p)
|
||||
nbtk_box_layout_get_preferred_width (ClutterActor *actor,
|
||||
gfloat for_height,
|
||||
gfloat *min_width_p,
|
||||
gfloat *natural_width_p)
|
||||
{
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (actor));
|
||||
|
||||
st_theme_node_adjust_for_height (theme_node, &for_height);
|
||||
shell_theme_node_adjust_for_height (theme_node, &for_height);
|
||||
|
||||
get_content_preferred_width (ST_BOX_LAYOUT (actor), for_height,
|
||||
get_content_preferred_width (NBTK_BOX_LAYOUT (actor), for_height,
|
||||
min_width_p, natural_width_p);
|
||||
|
||||
st_theme_node_adjust_preferred_width (theme_node,
|
||||
min_width_p, natural_width_p);
|
||||
shell_theme_node_adjust_preferred_width (theme_node,
|
||||
min_width_p, natural_width_p);
|
||||
}
|
||||
|
||||
static void
|
||||
get_content_preferred_height (StBoxLayout *self,
|
||||
gfloat for_width,
|
||||
gfloat *min_height_p,
|
||||
gfloat *natural_height_p)
|
||||
get_content_preferred_height (NbtkBoxLayout *self,
|
||||
gfloat for_width,
|
||||
gfloat *min_height_p,
|
||||
gfloat *natural_height_p)
|
||||
{
|
||||
StBoxLayoutPrivate *priv = self->priv;
|
||||
NbtkBoxLayoutPrivate *priv = self->priv;
|
||||
gint n_children = 0;
|
||||
gfloat min_height, natural_height;
|
||||
GList *l;
|
||||
@ -548,20 +542,20 @@ get_content_preferred_height (StBoxLayout *self,
|
||||
}
|
||||
|
||||
static void
|
||||
st_box_layout_get_preferred_height (ClutterActor *actor,
|
||||
gfloat for_width,
|
||||
gfloat *min_height_p,
|
||||
gfloat *natural_height_p)
|
||||
nbtk_box_layout_get_preferred_height (ClutterActor *actor,
|
||||
gfloat for_width,
|
||||
gfloat *min_height_p,
|
||||
gfloat *natural_height_p)
|
||||
{
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (actor));
|
||||
|
||||
st_theme_node_adjust_for_width (theme_node, &for_width);
|
||||
shell_theme_node_adjust_for_width (theme_node, &for_width);
|
||||
|
||||
get_content_preferred_height (ST_BOX_LAYOUT (actor), for_width,
|
||||
min_height_p, natural_height_p);
|
||||
get_content_preferred_height (NBTK_BOX_LAYOUT (actor), for_width,
|
||||
min_height_p, natural_height_p);
|
||||
|
||||
st_theme_node_adjust_preferred_height (theme_node,
|
||||
min_height_p, natural_height_p);
|
||||
shell_theme_node_adjust_preferred_height (theme_node,
|
||||
min_height_p, natural_height_p);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
@ -587,11 +581,11 @@ compare_by_child_index (const void *a,
|
||||
}
|
||||
|
||||
static BoxChildShrink *
|
||||
compute_shrinks (StBoxLayout *self,
|
||||
gfloat for_length,
|
||||
gfloat total_shrink)
|
||||
compute_shrinks (NbtkBoxLayout *self,
|
||||
gfloat for_length,
|
||||
gfloat total_shrink)
|
||||
{
|
||||
StBoxLayoutPrivate *priv = self->priv;
|
||||
NbtkBoxLayoutPrivate *priv = self->priv;
|
||||
int n_children = g_list_length (priv->children);
|
||||
BoxChildShrink *shrinks = g_new0 (BoxChildShrink, n_children);
|
||||
gfloat shrink_so_far, base_shrink;
|
||||
@ -608,7 +602,7 @@ compute_shrinks (StBoxLayout *self,
|
||||
|
||||
/* Find the amount of possible shrink for each child */
|
||||
int n_visible_children = 0;
|
||||
for (l = priv->children, i = 0; l; l = l->next, i++)
|
||||
for (l = priv->children; l; l = l->next, i++)
|
||||
{
|
||||
gfloat child_min, child_nat;
|
||||
|
||||
@ -684,12 +678,12 @@ compute_shrinks (StBoxLayout *self,
|
||||
}
|
||||
|
||||
static void
|
||||
st_box_layout_allocate (ClutterActor *actor,
|
||||
const ClutterActorBox *box,
|
||||
ClutterAllocationFlags flags)
|
||||
nbtk_box_layout_allocate (ClutterActor *actor,
|
||||
const ClutterActorBox *box,
|
||||
ClutterAllocationFlags flags)
|
||||
{
|
||||
StBoxLayoutPrivate *priv = ST_BOX_LAYOUT (actor)->priv;
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
||||
NbtkBoxLayoutPrivate *priv = NBTK_BOX_LAYOUT (actor)->priv;
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (actor));
|
||||
ClutterActorBox content_box;
|
||||
gfloat avail_width, avail_height, min_width, natural_width, min_height, natural_height;
|
||||
gfloat position, next_position;
|
||||
@ -698,20 +692,20 @@ st_box_layout_allocate (ClutterActor *actor,
|
||||
gfloat expand_amount, shrink_amount;
|
||||
BoxChildShrink *shrinks = NULL;
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_box_layout_parent_class)->allocate (actor, box,
|
||||
flags);
|
||||
CLUTTER_ACTOR_CLASS (nbtk_box_layout_parent_class)->allocate (actor, box,
|
||||
flags);
|
||||
|
||||
if (priv->children == NULL)
|
||||
return;
|
||||
|
||||
st_theme_node_get_content_box (theme_node, box, &content_box);
|
||||
shell_theme_node_get_content_box (theme_node, box, &content_box);
|
||||
|
||||
avail_width = content_box.x2 - content_box.x1;
|
||||
avail_height = content_box.y2 - content_box.y1;
|
||||
|
||||
get_content_preferred_height (ST_BOX_LAYOUT (actor), avail_width,
|
||||
get_content_preferred_height (NBTK_BOX_LAYOUT (actor), avail_width,
|
||||
&min_height, &natural_height);
|
||||
get_content_preferred_width (ST_BOX_LAYOUT (actor), avail_height,
|
||||
get_content_preferred_width (NBTK_BOX_LAYOUT (actor), avail_height,
|
||||
&min_width, &natural_width);
|
||||
|
||||
/* update adjustments for scrolling */
|
||||
@ -720,15 +714,15 @@ st_box_layout_allocate (ClutterActor *actor,
|
||||
gdouble prev_value;
|
||||
|
||||
g_object_set (G_OBJECT (priv->vadjustment),
|
||||
"lower", 0.0,
|
||||
"upper", natural_height,
|
||||
"page-size", avail_height,
|
||||
"step-increment", avail_height / 6,
|
||||
"page-increment", avail_height,
|
||||
NULL);
|
||||
"lower", 0.0,
|
||||
"upper", natural_height,
|
||||
"page-size", avail_height,
|
||||
"step-increment", avail_height / 6,
|
||||
"page-increment", avail_height,
|
||||
NULL);
|
||||
|
||||
prev_value = st_adjustment_get_value (priv->vadjustment);
|
||||
st_adjustment_set_value (priv->vadjustment, prev_value);
|
||||
prev_value = nbtk_adjustment_get_value (priv->vadjustment);
|
||||
nbtk_adjustment_set_value (priv->vadjustment, prev_value);
|
||||
}
|
||||
|
||||
if (priv->hadjustment)
|
||||
@ -736,15 +730,15 @@ st_box_layout_allocate (ClutterActor *actor,
|
||||
gdouble prev_value;
|
||||
|
||||
g_object_set (G_OBJECT (priv->hadjustment),
|
||||
"lower", 0.0,
|
||||
"upper", natural_width,
|
||||
"page-size", avail_width,
|
||||
"step-increment", avail_width / 6,
|
||||
"page-increment", avail_width,
|
||||
NULL);
|
||||
"lower", 0.0,
|
||||
"upper", natural_width,
|
||||
"page-size", avail_width,
|
||||
"step-increment", avail_width / 6,
|
||||
"page-increment", avail_width,
|
||||
NULL);
|
||||
|
||||
prev_value = st_adjustment_get_value (priv->hadjustment);
|
||||
st_adjustment_set_value (priv->hadjustment, prev_value);
|
||||
prev_value = nbtk_adjustment_get_value (priv->hadjustment);
|
||||
nbtk_adjustment_set_value (priv->hadjustment, prev_value);
|
||||
}
|
||||
|
||||
if (priv->is_vertical)
|
||||
@ -782,10 +776,10 @@ st_box_layout_allocate (ClutterActor *actor,
|
||||
}
|
||||
else if (shrink_amount > 0)
|
||||
{
|
||||
shrinks = compute_shrinks (ST_BOX_LAYOUT (actor),
|
||||
shrinks = compute_shrinks (NBTK_BOX_LAYOUT (actor),
|
||||
priv->is_vertical ? avail_width : avail_height,
|
||||
shrink_amount);
|
||||
}
|
||||
}
|
||||
|
||||
if (priv->is_vertical)
|
||||
position = content_box.y1;
|
||||
@ -809,7 +803,7 @@ st_box_layout_allocate (ClutterActor *actor,
|
||||
ClutterActorBox child_box;
|
||||
gfloat child_min, child_nat, child_allocated;
|
||||
gboolean xfill, yfill, expand;
|
||||
StAlign xalign, yalign;
|
||||
NbtkAlign xalign, yalign;
|
||||
|
||||
if (!CLUTTER_ACTOR_IS_VISIBLE (child))
|
||||
goto next_child;
|
||||
@ -851,7 +845,7 @@ st_box_layout_allocate (ClutterActor *actor,
|
||||
else
|
||||
child_box.x2 = content_box.x2;
|
||||
|
||||
_st_allocate_fill (child, &child_box, xalign, yalign, xfill, yfill);
|
||||
_nbtk_allocate_fill (child, &child_box, xalign, yalign, xfill, yfill);
|
||||
clutter_actor_allocate (child, &child_box, flags);
|
||||
|
||||
}
|
||||
@ -865,7 +859,7 @@ st_box_layout_allocate (ClutterActor *actor,
|
||||
else
|
||||
child_box.y2 = content_box.y2;
|
||||
|
||||
_st_allocate_fill (child, &child_box, xalign, yalign, xfill, yfill);
|
||||
_nbtk_allocate_fill (child, &child_box, xalign, yalign, xfill, yfill);
|
||||
clutter_actor_allocate (child, &child_box, flags);
|
||||
}
|
||||
|
||||
@ -889,21 +883,20 @@ st_box_layout_allocate (ClutterActor *actor,
|
||||
}
|
||||
|
||||
static void
|
||||
st_box_layout_apply_transform (ClutterActor *a,
|
||||
CoglMatrix *m)
|
||||
nbtk_box_layout_apply_transform (ClutterActor *a, CoglMatrix *m)
|
||||
{
|
||||
StBoxLayoutPrivate *priv = ST_BOX_LAYOUT (a)->priv;
|
||||
NbtkBoxLayoutPrivate *priv = NBTK_BOX_LAYOUT (a)->priv;
|
||||
gdouble x, y;
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_box_layout_parent_class)->apply_transform (a, m);
|
||||
CLUTTER_ACTOR_CLASS (nbtk_box_layout_parent_class)->apply_transform (a, m);
|
||||
|
||||
if (priv->hadjustment)
|
||||
x = st_adjustment_get_value (priv->hadjustment);
|
||||
x = nbtk_adjustment_get_value (priv->hadjustment);
|
||||
else
|
||||
x = 0;
|
||||
|
||||
if (priv->vadjustment)
|
||||
y = st_adjustment_get_value (priv->vadjustment);
|
||||
y = nbtk_adjustment_get_value (priv->vadjustment);
|
||||
else
|
||||
y = 0;
|
||||
|
||||
@ -912,10 +905,10 @@ st_box_layout_apply_transform (ClutterActor *a,
|
||||
|
||||
|
||||
static void
|
||||
st_box_layout_paint (ClutterActor *actor)
|
||||
nbtk_box_layout_paint (ClutterActor *actor)
|
||||
{
|
||||
StBoxLayoutPrivate *priv = ST_BOX_LAYOUT (actor)->priv;
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
||||
NbtkBoxLayoutPrivate *priv = NBTK_BOX_LAYOUT (actor)->priv;
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (actor));
|
||||
GList *l;
|
||||
gdouble x, y;
|
||||
ClutterActorBox child_box;
|
||||
@ -923,12 +916,12 @@ st_box_layout_paint (ClutterActor *actor)
|
||||
ClutterActorBox content_box;
|
||||
|
||||
if (priv->hadjustment)
|
||||
x = st_adjustment_get_value (priv->hadjustment);
|
||||
x = nbtk_adjustment_get_value (priv->hadjustment);
|
||||
else
|
||||
x = 0;
|
||||
|
||||
if (priv->vadjustment)
|
||||
y = st_adjustment_get_value (priv->vadjustment);
|
||||
y = nbtk_adjustment_get_value (priv->vadjustment);
|
||||
else
|
||||
y = 0;
|
||||
|
||||
@ -940,7 +933,7 @@ st_box_layout_paint (ClutterActor *actor)
|
||||
cogl_translate ((int)x, (int)y, 0);
|
||||
}
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_box_layout_parent_class)->paint (actor);
|
||||
CLUTTER_ACTOR_CLASS (nbtk_box_layout_parent_class)->paint (actor);
|
||||
|
||||
if (x != 0 || y != 0)
|
||||
{
|
||||
@ -951,7 +944,7 @@ st_box_layout_paint (ClutterActor *actor)
|
||||
return;
|
||||
|
||||
clutter_actor_get_allocation_box (actor, &allocation_box);
|
||||
st_theme_node_get_content_box (theme_node, &allocation_box, &content_box);
|
||||
shell_theme_node_get_content_box (theme_node, &allocation_box, &content_box);
|
||||
|
||||
content_box.x1 += x;
|
||||
content_box.y1 += y;
|
||||
@ -990,11 +983,11 @@ st_box_layout_paint (ClutterActor *actor)
|
||||
}
|
||||
|
||||
static void
|
||||
st_box_layout_pick (ClutterActor *actor,
|
||||
const ClutterColor *color)
|
||||
nbtk_box_layout_pick (ClutterActor *actor,
|
||||
const ClutterColor *color)
|
||||
{
|
||||
StBoxLayoutPrivate *priv = ST_BOX_LAYOUT (actor)->priv;
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
||||
NbtkBoxLayoutPrivate *priv = NBTK_BOX_LAYOUT (actor)->priv;
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (actor));
|
||||
GList *l;
|
||||
gdouble x, y;
|
||||
ClutterActorBox child_box;
|
||||
@ -1002,12 +995,12 @@ st_box_layout_pick (ClutterActor *actor,
|
||||
ClutterActorBox content_box;
|
||||
|
||||
if (priv->hadjustment)
|
||||
x = st_adjustment_get_value (priv->hadjustment);
|
||||
x = nbtk_adjustment_get_value (priv->hadjustment);
|
||||
else
|
||||
x = 0;
|
||||
|
||||
if (priv->vadjustment)
|
||||
y = st_adjustment_get_value (priv->vadjustment);
|
||||
y = nbtk_adjustment_get_value (priv->vadjustment);
|
||||
else
|
||||
y = 0;
|
||||
|
||||
@ -1017,7 +1010,7 @@ st_box_layout_pick (ClutterActor *actor,
|
||||
cogl_translate ((int)x, (int)y, 0);
|
||||
}
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_box_layout_parent_class)->pick (actor, color);
|
||||
CLUTTER_ACTOR_CLASS (nbtk_box_layout_parent_class)->pick (actor, color);
|
||||
|
||||
if (x != 0 || y != 0)
|
||||
{
|
||||
@ -1028,7 +1021,7 @@ st_box_layout_pick (ClutterActor *actor,
|
||||
return;
|
||||
|
||||
clutter_actor_get_allocation_box (actor, &allocation_box);
|
||||
st_theme_node_get_content_box (theme_node, &allocation_box, &content_box);
|
||||
shell_theme_node_get_content_box (theme_node, &allocation_box, &content_box);
|
||||
|
||||
content_box.x1 += x;
|
||||
content_box.y1 += y;
|
||||
@ -1064,61 +1057,49 @@ st_box_layout_pick (ClutterActor *actor,
|
||||
}
|
||||
|
||||
static void
|
||||
st_box_layout_style_changed (StWidget *self)
|
||||
{
|
||||
StBoxLayoutPrivate *priv = ST_BOX_LAYOUT (self)->priv;
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (self);
|
||||
int old_spacing = priv->spacing;
|
||||
double spacing = 0;
|
||||
|
||||
st_theme_node_get_length (theme_node, "spacing", FALSE, &spacing);
|
||||
priv->spacing = (int)(spacing + 0.5);
|
||||
if (priv->spacing != old_spacing)
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (self));
|
||||
|
||||
ST_WIDGET_CLASS (st_box_layout_parent_class)->style_changed (self);
|
||||
}
|
||||
|
||||
static void
|
||||
st_box_layout_class_init (StBoxLayoutClass *klass)
|
||||
nbtk_box_layout_class_init (NbtkBoxLayoutClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
||||
StWidgetClass *widget_class = ST_WIDGET_CLASS (klass);
|
||||
GParamSpec *pspec;
|
||||
|
||||
g_type_class_add_private (klass, sizeof (StBoxLayoutPrivate));
|
||||
g_type_class_add_private (klass, sizeof (NbtkBoxLayoutPrivate));
|
||||
|
||||
object_class->get_property = st_box_layout_get_property;
|
||||
object_class->set_property = st_box_layout_set_property;
|
||||
object_class->dispose = st_box_layout_dispose;
|
||||
object_class->get_property = nbtk_box_layout_get_property;
|
||||
object_class->set_property = nbtk_box_layout_set_property;
|
||||
object_class->dispose = nbtk_box_layout_dispose;
|
||||
|
||||
actor_class->allocate = st_box_layout_allocate;
|
||||
actor_class->get_preferred_width = st_box_layout_get_preferred_width;
|
||||
actor_class->get_preferred_height = st_box_layout_get_preferred_height;
|
||||
actor_class->apply_transform = st_box_layout_apply_transform;
|
||||
actor_class->allocate = nbtk_box_layout_allocate;
|
||||
actor_class->get_preferred_width = nbtk_box_layout_get_preferred_width;
|
||||
actor_class->get_preferred_height = nbtk_box_layout_get_preferred_height;
|
||||
actor_class->apply_transform = nbtk_box_layout_apply_transform;
|
||||
|
||||
actor_class->paint = st_box_layout_paint;
|
||||
actor_class->pick = st_box_layout_pick;
|
||||
|
||||
widget_class->style_changed = st_box_layout_style_changed;
|
||||
actor_class->paint = nbtk_box_layout_paint;
|
||||
actor_class->pick = nbtk_box_layout_pick;
|
||||
|
||||
pspec = g_param_spec_boolean ("vertical",
|
||||
"Vertical",
|
||||
"Whether the layout should be vertical, rather"
|
||||
"than horizontal",
|
||||
FALSE,
|
||||
ST_PARAM_READWRITE);
|
||||
NBTK_PARAM_READWRITE);
|
||||
g_object_class_install_property (object_class, PROP_VERTICAL, pspec);
|
||||
|
||||
pspec = g_param_spec_boolean ("pack-start",
|
||||
"Pack Start",
|
||||
"Whether to pack items at the start of the box",
|
||||
FALSE,
|
||||
ST_PARAM_READWRITE);
|
||||
NBTK_PARAM_READWRITE);
|
||||
g_object_class_install_property (object_class, PROP_PACK_START, pspec);
|
||||
|
||||
/* StScrollable properties */
|
||||
pspec = g_param_spec_uint ("spacing",
|
||||
"Spacing",
|
||||
"Spacing between children",
|
||||
0, G_MAXUINT, 0,
|
||||
NBTK_PARAM_READWRITE);
|
||||
g_object_class_install_property (object_class, PROP_SPACING, pspec);
|
||||
|
||||
/* NbtkScrollable properties */
|
||||
g_object_class_override_property (object_class,
|
||||
PROP_HADJUST,
|
||||
"hadjustment");
|
||||
@ -1130,37 +1111,37 @@ st_box_layout_class_init (StBoxLayoutClass *klass)
|
||||
}
|
||||
|
||||
static void
|
||||
st_box_layout_init (StBoxLayout *self)
|
||||
nbtk_box_layout_init (NbtkBoxLayout *self)
|
||||
{
|
||||
self->priv = BOX_LAYOUT_PRIVATE (self);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_box_layout_new:
|
||||
* nbtk_box_layout_new:
|
||||
*
|
||||
* Create a new #StBoxLayout.
|
||||
* Create a new #NbtkBoxLayout.
|
||||
*
|
||||
* Returns: a newly allocated #StBoxLayout
|
||||
* Returns: a newly allocated #NbtkBoxLayout
|
||||
*/
|
||||
StWidget *
|
||||
st_box_layout_new (void)
|
||||
NbtkWidget *
|
||||
nbtk_box_layout_new (void)
|
||||
{
|
||||
return g_object_new (ST_TYPE_BOX_LAYOUT, NULL);
|
||||
return g_object_new (NBTK_TYPE_BOX_LAYOUT, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_box_layout_set_vertical:
|
||||
* @box: A #StBoxLayout
|
||||
* nbtk_box_layout_set_vertical:
|
||||
* @box: A #NbtkBoxLayout
|
||||
* @vertical: #TRUE if the layout should be vertical
|
||||
*
|
||||
* Set the value of the #StBoxLayout::vertical property
|
||||
* Set the value of the #NbtkBoxLayout::vertical property
|
||||
*
|
||||
*/
|
||||
void
|
||||
st_box_layout_set_vertical (StBoxLayout *box,
|
||||
gboolean vertical)
|
||||
nbtk_box_layout_set_vertical (NbtkBoxLayout *box,
|
||||
gboolean vertical)
|
||||
{
|
||||
g_return_if_fail (ST_IS_BOX_LAYOUT (box));
|
||||
g_return_if_fail (NBTK_IS_BOX_LAYOUT (box));
|
||||
|
||||
if (box->priv->is_vertical != vertical)
|
||||
{
|
||||
@ -1172,34 +1153,34 @@ st_box_layout_set_vertical (StBoxLayout *box,
|
||||
}
|
||||
|
||||
/**
|
||||
* st_box_layout_get_vertical:
|
||||
* @box: A #StBoxLayout
|
||||
* nbtk_box_layout_get_vertical:
|
||||
* @box: A #NbtkBoxLayout
|
||||
*
|
||||
* Get the value of the #StBoxLayout::vertical property.
|
||||
* Get the value of the #NbtkBoxLayout::vertical property.
|
||||
*
|
||||
* Returns: #TRUE if the layout is vertical
|
||||
*/
|
||||
gboolean
|
||||
st_box_layout_get_vertical (StBoxLayout *box)
|
||||
nbtk_box_layout_get_vertical (NbtkBoxLayout *box)
|
||||
{
|
||||
g_return_val_if_fail (ST_IS_BOX_LAYOUT (box), FALSE);
|
||||
g_return_val_if_fail (NBTK_IS_BOX_LAYOUT (box), FALSE);
|
||||
|
||||
return box->priv->is_vertical;
|
||||
}
|
||||
|
||||
/**
|
||||
* st_box_layout_set_pack_start:
|
||||
* @box: A #StBoxLayout
|
||||
* nbtk_box_layout_set_pack_start:
|
||||
* @box: A #NbtkBoxLayout
|
||||
* @pack_start: #TRUE if the layout should use pack-start
|
||||
*
|
||||
* Set the value of the #StBoxLayout::pack-start property.
|
||||
* Set the value of the #NbtkBoxLayout::pack-start property.
|
||||
*
|
||||
*/
|
||||
void
|
||||
st_box_layout_set_pack_start (StBoxLayout *box,
|
||||
gboolean pack_start)
|
||||
nbtk_box_layout_set_pack_start (NbtkBoxLayout *box,
|
||||
gboolean pack_start)
|
||||
{
|
||||
g_return_if_fail (ST_IS_BOX_LAYOUT (box));
|
||||
g_return_if_fail (NBTK_IS_BOX_LAYOUT (box));
|
||||
|
||||
if (box->priv->is_pack_start != pack_start)
|
||||
{
|
||||
@ -1211,17 +1192,61 @@ st_box_layout_set_pack_start (StBoxLayout *box,
|
||||
}
|
||||
|
||||
/**
|
||||
* st_box_layout_get_pack_start:
|
||||
* @box: A #StBoxLayout
|
||||
* nbtk_box_layout_get_pack_start:
|
||||
* @box: A #NbtkBoxLayout
|
||||
*
|
||||
* Get the value of the #StBoxLayout::pack-start property.
|
||||
* Get the value of the #NbtkBoxLayout::pack-start property.
|
||||
*
|
||||
* Returns: #TRUE if pack-start is enabled
|
||||
*/
|
||||
gboolean
|
||||
st_box_layout_get_pack_start (StBoxLayout *box)
|
||||
nbtk_box_layout_get_pack_start (NbtkBoxLayout *box)
|
||||
{
|
||||
g_return_val_if_fail (ST_IS_BOX_LAYOUT (box), FALSE);
|
||||
g_return_val_if_fail (NBTK_IS_BOX_LAYOUT (box), FALSE);
|
||||
|
||||
return box->priv->is_pack_start;
|
||||
}
|
||||
|
||||
/**
|
||||
* nbtk_box_layout_set_spacing:
|
||||
* @box: A #NbtkBoxLayout
|
||||
* @spacing: the spacing value
|
||||
*
|
||||
* Set the amount of spacing between children in pixels
|
||||
*
|
||||
*/
|
||||
void
|
||||
nbtk_box_layout_set_spacing (NbtkBoxLayout *box,
|
||||
guint spacing)
|
||||
{
|
||||
NbtkBoxLayoutPrivate *priv;
|
||||
|
||||
g_return_if_fail (NBTK_IS_BOX_LAYOUT (box));
|
||||
|
||||
priv = box->priv;
|
||||
|
||||
if (priv->spacing != spacing)
|
||||
{
|
||||
priv->spacing = spacing;
|
||||
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (box));
|
||||
|
||||
g_object_notify (G_OBJECT (box), "spacing");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* nbtk_box_layout_get_spacing:
|
||||
* @box: A #NbtkBoxLayout
|
||||
*
|
||||
* Get the spacing between children in pixels
|
||||
*
|
||||
* Returns: the spacing value
|
||||
*/
|
||||
guint
|
||||
nbtk_box_layout_get_spacing (NbtkBoxLayout *box)
|
||||
{
|
||||
g_return_val_if_fail (NBTK_IS_BOX_LAYOUT (box), 0);
|
||||
|
||||
return box->priv->spacing;
|
||||
}
|
91
src/nbtk/nbtk-box-layout.h
Normal file
91
src/nbtk/nbtk-box-layout.h
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* nbtk-box-layout.h: box layout actor
|
||||
*
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Written by: Thomas Wood <thomas.wood@intel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _NBTK_BOX_LAYOUT_H
|
||||
#define _NBTK_BOX_LAYOUT_H
|
||||
|
||||
#include <nbtk/nbtk-widget.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NBTK_TYPE_BOX_LAYOUT nbtk_box_layout_get_type()
|
||||
|
||||
#define NBTK_BOX_LAYOUT(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
||||
NBTK_TYPE_BOX_LAYOUT, NbtkBoxLayout))
|
||||
|
||||
#define NBTK_BOX_LAYOUT_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), \
|
||||
NBTK_TYPE_BOX_LAYOUT, NbtkBoxLayoutClass))
|
||||
|
||||
#define NBTK_IS_BOX_LAYOUT(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
|
||||
NBTK_TYPE_BOX_LAYOUT))
|
||||
|
||||
#define NBTK_IS_BOX_LAYOUT_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
|
||||
NBTK_TYPE_BOX_LAYOUT))
|
||||
|
||||
#define NBTK_BOX_LAYOUT_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
|
||||
NBTK_TYPE_BOX_LAYOUT, NbtkBoxLayoutClass))
|
||||
|
||||
typedef struct _NbtkBoxLayout NbtkBoxLayout;
|
||||
typedef struct _NbtkBoxLayoutClass NbtkBoxLayoutClass;
|
||||
typedef struct _NbtkBoxLayoutPrivate NbtkBoxLayoutPrivate;
|
||||
|
||||
/**
|
||||
* NbtkBoxLayout:
|
||||
*
|
||||
* The contents of this structure are private and should only be accessed
|
||||
* through the public API.
|
||||
*/
|
||||
struct _NbtkBoxLayout
|
||||
{
|
||||
/*< private >*/
|
||||
NbtkWidget parent;
|
||||
|
||||
NbtkBoxLayoutPrivate *priv;
|
||||
};
|
||||
|
||||
struct _NbtkBoxLayoutClass
|
||||
{
|
||||
NbtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
GType nbtk_box_layout_get_type (void);
|
||||
|
||||
NbtkWidget *nbtk_box_layout_new (void);
|
||||
|
||||
void nbtk_box_layout_set_vertical (NbtkBoxLayout *box, gboolean vertical);
|
||||
gboolean nbtk_box_layout_get_vertical (NbtkBoxLayout *box);
|
||||
|
||||
void nbtk_box_layout_set_pack_start (NbtkBoxLayout *box, gboolean pack_start);
|
||||
gboolean nbtk_box_layout_get_pack_start (NbtkBoxLayout *box);
|
||||
|
||||
void nbtk_box_layout_set_spacing (NbtkBoxLayout *box, guint spacing);
|
||||
guint nbtk_box_layout_get_spacing (NbtkBoxLayout *box);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _NBTK_BOX_LAYOUT_H */
|
@ -1,9 +1,6 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-button.c: Plain button actor
|
||||
*
|
||||
/*-button.c: Plain button actor
|
||||
* Copyright 2007 OpenedHand
|
||||
* Copyright 2008, 2009 Intel Corporation.
|
||||
* Copyright , 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
@ -24,7 +21,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:st-button
|
||||
* SECTION:nbtk-button
|
||||
* @short_description: Button widget
|
||||
*
|
||||
* A button widget with support for either a text label or icon, toggle mode
|
||||
@ -43,21 +40,21 @@
|
||||
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
#include "st-button.h"
|
||||
#include "nbtk-button.h"
|
||||
|
||||
#include "st-marshal.h"
|
||||
#include "st-texture-frame.h"
|
||||
#include "st-texture-cache.h"
|
||||
#include "st-private.h"
|
||||
#include "nbtk-marshal.h"
|
||||
#include "nbtk-texture-frame.h"
|
||||
#include "nbtk-texture-cache.h"
|
||||
#include "nbtk-private.h"
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
||||
PROP_LABEL,
|
||||
PROP_TOGGLE_MODE,
|
||||
PROP_CHECKED,
|
||||
PROP_TRANSITION_DURATION
|
||||
PROP_TOGGLE,
|
||||
PROP_ACTIVE,
|
||||
PROP_TRANSITION
|
||||
};
|
||||
|
||||
enum
|
||||
@ -67,64 +64,64 @@ enum
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
#define ST_BUTTON_GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), ST_TYPE_BUTTON, StButtonPrivate))
|
||||
#define NBTK_BUTTON_GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), NBTK_TYPE_BUTTON, NbtkButtonPrivate))
|
||||
|
||||
struct _StButtonPrivate
|
||||
struct _NbtkButtonPrivate
|
||||
{
|
||||
gchar *text;
|
||||
gchar *text;
|
||||
|
||||
ClutterActor *old_bg;
|
||||
gboolean old_bg_parented; /* TRUE if we have adopted old_bg */
|
||||
ClutterActor *old_bg;
|
||||
gboolean old_bg_parented; /* TRUE if we have adopted old_bg */
|
||||
|
||||
guint8 old_opacity;
|
||||
guint8 old_opacity;
|
||||
|
||||
guint is_pressed : 1;
|
||||
guint is_hover : 1;
|
||||
guint is_checked : 1;
|
||||
guint is_toggle : 1;
|
||||
guint is_pressed : 1;
|
||||
guint is_hover : 1;
|
||||
guint is_checked : 1;
|
||||
guint is_toggle : 1;
|
||||
|
||||
gint transition_duration;
|
||||
gint transition_duration;
|
||||
|
||||
ClutterAnimation *animation;
|
||||
|
||||
gint spacing;
|
||||
gint spacing;
|
||||
};
|
||||
|
||||
static guint button_signals[LAST_SIGNAL] = { 0, };
|
||||
|
||||
G_DEFINE_TYPE (StButton, st_button, ST_TYPE_BIN);
|
||||
G_DEFINE_TYPE (NbtkButton, nbtk_button, NBTK_TYPE_BIN);
|
||||
|
||||
static void
|
||||
st_button_update_label_style (StButton *button)
|
||||
nbtk_button_update_label_style (NbtkButton *button)
|
||||
{
|
||||
ClutterActor *label;
|
||||
StThemeNode *theme_node;
|
||||
ShellThemeNode *theme_node;
|
||||
ClutterColor color;
|
||||
const PangoFontDescription *font;
|
||||
gchar *font_string = NULL;
|
||||
|
||||
label = st_bin_get_child ((StBin*) button);
|
||||
label = nbtk_bin_get_child ((NbtkBin*) button);
|
||||
|
||||
/* check the child is really a label */
|
||||
if (!CLUTTER_IS_TEXT (label))
|
||||
return;
|
||||
|
||||
theme_node = st_widget_get_theme_node (ST_WIDGET (button));
|
||||
theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (button));
|
||||
|
||||
st_theme_node_get_foreground_color (theme_node, &color);
|
||||
shell_theme_node_get_foreground_color (theme_node, &color);
|
||||
clutter_text_set_color (CLUTTER_TEXT (label), &color);
|
||||
|
||||
font = st_theme_node_get_font (theme_node);
|
||||
font = shell_theme_node_get_font (theme_node);
|
||||
font_string = pango_font_description_to_string (font);
|
||||
clutter_text_set_font_name (CLUTTER_TEXT (label), font_string);
|
||||
g_free (font_string);
|
||||
}
|
||||
|
||||
static void
|
||||
st_button_dispose_old_bg (StButton *button)
|
||||
nbtk_button_dispose_old_bg (NbtkButton *button)
|
||||
{
|
||||
StButtonPrivate *priv = button->priv;
|
||||
NbtkButtonPrivate *priv = button->priv;
|
||||
|
||||
if (priv->old_bg)
|
||||
{
|
||||
@ -139,36 +136,36 @@ st_button_dispose_old_bg (StButton *button)
|
||||
}
|
||||
|
||||
static void
|
||||
st_animation_completed (ClutterAnimation *animation,
|
||||
StButton *button)
|
||||
nbtk_animation_completed (ClutterAnimation *animation,
|
||||
NbtkButton *button)
|
||||
{
|
||||
st_button_dispose_old_bg (button);
|
||||
nbtk_button_dispose_old_bg (button);
|
||||
}
|
||||
|
||||
static void
|
||||
st_button_style_changed (StWidget *widget)
|
||||
nbtk_button_style_changed (NbtkWidget *widget)
|
||||
{
|
||||
StButton *button = ST_BUTTON (widget);
|
||||
StButtonPrivate *priv = button->priv;
|
||||
StButtonClass *button_class = ST_BUTTON_GET_CLASS (button);
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (button));
|
||||
NbtkButton *button = NBTK_BUTTON (widget);
|
||||
NbtkButtonPrivate *priv = button->priv;
|
||||
NbtkButtonClass *button_class = NBTK_BUTTON_GET_CLASS (button);
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (button));
|
||||
ClutterActor *bg_image;
|
||||
double spacing;
|
||||
|
||||
st_button_dispose_old_bg (button);
|
||||
nbtk_button_dispose_old_bg (button);
|
||||
|
||||
bg_image = st_widget_get_border_image ((StWidget*) button);
|
||||
bg_image = nbtk_widget_get_border_image ((NbtkWidget*) button);
|
||||
if (bg_image)
|
||||
button->priv->old_bg = g_object_ref (bg_image);
|
||||
|
||||
ST_WIDGET_CLASS (st_button_parent_class)->style_changed (widget);
|
||||
NBTK_WIDGET_CLASS (nbtk_button_parent_class)->style_changed (widget);
|
||||
|
||||
spacing = 6;
|
||||
st_theme_node_get_length (theme_node, "border-spacing", FALSE, &spacing);
|
||||
shell_theme_node_get_length (theme_node, "border-spacing", FALSE, &spacing);
|
||||
priv->spacing = round (spacing);
|
||||
|
||||
/* update the label styling */
|
||||
st_button_update_label_style (button);
|
||||
nbtk_button_update_label_style (button);
|
||||
|
||||
/* run a transition if applicable */
|
||||
if (button_class->transition)
|
||||
@ -178,7 +175,7 @@ st_button_style_changed (StWidget *widget)
|
||||
else
|
||||
{
|
||||
if (priv->old_bg &&
|
||||
(!st_widget_get_style_pseudo_class (widget)))
|
||||
(!nbtk_widget_get_style_pseudo_class (widget)))
|
||||
{
|
||||
ClutterAnimation *animation;
|
||||
if (!clutter_actor_get_parent (priv->old_bg))
|
||||
@ -194,11 +191,11 @@ st_button_style_changed (StWidget *widget)
|
||||
"opacity", 0,
|
||||
NULL);
|
||||
g_signal_connect (animation, "completed",
|
||||
G_CALLBACK (st_animation_completed), button);
|
||||
G_CALLBACK (nbtk_animation_completed), button);
|
||||
}
|
||||
else
|
||||
{
|
||||
st_button_dispose_old_bg (button);
|
||||
nbtk_button_dispose_old_bg (button);
|
||||
}
|
||||
|
||||
}
|
||||
@ -206,35 +203,35 @@ st_button_style_changed (StWidget *widget)
|
||||
}
|
||||
|
||||
static void
|
||||
st_button_real_pressed (StButton *button)
|
||||
nbtk_button_real_pressed (NbtkButton *button)
|
||||
{
|
||||
st_widget_set_style_pseudo_class ((StWidget*) button, "active");
|
||||
nbtk_widget_set_style_pseudo_class ((NbtkWidget*) button, "active");
|
||||
}
|
||||
|
||||
static void
|
||||
st_button_real_released (StButton *button)
|
||||
nbtk_button_real_released (NbtkButton *button)
|
||||
{
|
||||
StButtonPrivate *priv = button->priv;
|
||||
NbtkButtonPrivate *priv = button->priv;
|
||||
|
||||
if (priv->is_checked)
|
||||
st_widget_set_style_pseudo_class ((StWidget*) button, "checked");
|
||||
nbtk_widget_set_style_pseudo_class ((NbtkWidget*) button, "checked");
|
||||
else if (!priv->is_hover)
|
||||
st_widget_set_style_pseudo_class ((StWidget*) button, NULL);
|
||||
nbtk_widget_set_style_pseudo_class ((NbtkWidget*) button, NULL);
|
||||
else
|
||||
st_widget_set_style_pseudo_class ((StWidget*) button, "hover");
|
||||
nbtk_widget_set_style_pseudo_class ((NbtkWidget*) button, "hover");
|
||||
|
||||
}
|
||||
|
||||
static gboolean
|
||||
st_button_button_press (ClutterActor *actor,
|
||||
ClutterButtonEvent *event)
|
||||
nbtk_button_button_press (ClutterActor *actor,
|
||||
ClutterButtonEvent *event)
|
||||
{
|
||||
st_widget_hide_tooltip (ST_WIDGET (actor));
|
||||
nbtk_widget_hide_tooltip (NBTK_WIDGET (actor));
|
||||
|
||||
if (event->button == 1)
|
||||
{
|
||||
StButton *button = ST_BUTTON (actor);
|
||||
StButtonClass *klass = ST_BUTTON_GET_CLASS (button);
|
||||
NbtkButton *button = NBTK_BUTTON (actor);
|
||||
NbtkButtonClass *klass = NBTK_BUTTON_GET_CLASS (button);
|
||||
|
||||
button->priv->is_pressed = TRUE;
|
||||
|
||||
@ -250,13 +247,13 @@ st_button_button_press (ClutterActor *actor,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
st_button_button_release (ClutterActor *actor,
|
||||
ClutterButtonEvent *event)
|
||||
nbtk_button_button_release (ClutterActor *actor,
|
||||
ClutterButtonEvent *event)
|
||||
{
|
||||
if (event->button == 1)
|
||||
{
|
||||
StButton *button = ST_BUTTON (actor);
|
||||
StButtonClass *klass = ST_BUTTON_GET_CLASS (button);
|
||||
NbtkButton *button = NBTK_BUTTON (actor);
|
||||
NbtkButtonClass *klass = NBTK_BUTTON_GET_CLASS (button);
|
||||
|
||||
if (!button->priv->is_pressed)
|
||||
return FALSE;
|
||||
@ -265,7 +262,7 @@ st_button_button_release (ClutterActor *actor,
|
||||
|
||||
if (button->priv->is_toggle)
|
||||
{
|
||||
st_button_set_checked (button, !button->priv->is_checked);
|
||||
nbtk_button_set_checked (button, !button->priv->is_checked);
|
||||
}
|
||||
|
||||
button->priv->is_pressed = FALSE;
|
||||
@ -282,30 +279,30 @@ st_button_button_release (ClutterActor *actor,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
st_button_enter (ClutterActor *actor,
|
||||
ClutterCrossingEvent *event)
|
||||
nbtk_button_enter (ClutterActor *actor,
|
||||
ClutterCrossingEvent *event)
|
||||
{
|
||||
StButton *button = ST_BUTTON (actor);
|
||||
NbtkButton *button = NBTK_BUTTON (actor);
|
||||
|
||||
if (!button->priv->is_checked)
|
||||
st_widget_set_style_pseudo_class ((StWidget*) button, "hover");
|
||||
nbtk_widget_set_style_pseudo_class ((NbtkWidget*) button, "hover");
|
||||
|
||||
button->priv->is_hover = 1;
|
||||
|
||||
return CLUTTER_ACTOR_CLASS (st_button_parent_class)->enter_event (actor, event);
|
||||
return CLUTTER_ACTOR_CLASS (nbtk_button_parent_class)->enter_event (actor, event);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
st_button_leave (ClutterActor *actor,
|
||||
ClutterCrossingEvent *event)
|
||||
nbtk_button_leave (ClutterActor *actor,
|
||||
ClutterCrossingEvent *event)
|
||||
{
|
||||
StButton *button = ST_BUTTON (actor);
|
||||
NbtkButton *button = NBTK_BUTTON (actor);
|
||||
|
||||
button->priv->is_hover = 0;
|
||||
|
||||
if (button->priv->is_pressed)
|
||||
{
|
||||
StButtonClass *klass = ST_BUTTON_GET_CLASS (button);
|
||||
NbtkButtonClass *klass = NBTK_BUTTON_GET_CLASS (button);
|
||||
|
||||
clutter_ungrab_pointer ();
|
||||
|
||||
@ -316,34 +313,34 @@ st_button_leave (ClutterActor *actor,
|
||||
}
|
||||
|
||||
if (button->priv->is_checked)
|
||||
st_widget_set_style_pseudo_class ((StWidget*) button, "checked");
|
||||
nbtk_widget_set_style_pseudo_class ((NbtkWidget*) button, "checked");
|
||||
else
|
||||
st_widget_set_style_pseudo_class ((StWidget*) button, NULL);
|
||||
nbtk_widget_set_style_pseudo_class ((NbtkWidget*) button, NULL);
|
||||
|
||||
return CLUTTER_ACTOR_CLASS (st_button_parent_class)->leave_event (actor, event);
|
||||
return CLUTTER_ACTOR_CLASS (nbtk_button_parent_class)->leave_event (actor, event);
|
||||
}
|
||||
|
||||
static void
|
||||
st_button_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
nbtk_button_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StButton *button = ST_BUTTON (gobject);
|
||||
StButtonPrivate *priv = ST_BUTTON (gobject)->priv;
|
||||
NbtkButton *button = NBTK_BUTTON (gobject);
|
||||
NbtkButtonPrivate *priv = NBTK_BUTTON (gobject)->priv;
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_LABEL:
|
||||
st_button_set_label (button, g_value_get_string (value));
|
||||
nbtk_button_set_label (button, g_value_get_string (value));
|
||||
break;
|
||||
case PROP_TOGGLE_MODE:
|
||||
st_button_set_toggle_mode (button, g_value_get_boolean (value));
|
||||
case PROP_TOGGLE:
|
||||
nbtk_button_set_toggle_mode (button, g_value_get_boolean (value));
|
||||
break;
|
||||
case PROP_CHECKED:
|
||||
st_button_set_checked (button, g_value_get_boolean (value));
|
||||
case PROP_ACTIVE:
|
||||
nbtk_button_set_checked (button, g_value_get_boolean (value));
|
||||
break;
|
||||
case PROP_TRANSITION_DURATION:
|
||||
case PROP_TRANSITION:
|
||||
priv->transition_duration = g_value_get_int (value);
|
||||
break;
|
||||
|
||||
@ -355,25 +352,25 @@ st_button_set_property (GObject *gobject,
|
||||
}
|
||||
|
||||
static void
|
||||
st_button_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
nbtk_button_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StButtonPrivate *priv = ST_BUTTON (gobject)->priv;
|
||||
NbtkButtonPrivate *priv = NBTK_BUTTON (gobject)->priv;
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_LABEL:
|
||||
g_value_set_string (value, priv->text);
|
||||
break;
|
||||
case PROP_TOGGLE_MODE:
|
||||
case PROP_TOGGLE:
|
||||
g_value_set_boolean (value, priv->is_toggle);
|
||||
break;
|
||||
case PROP_CHECKED:
|
||||
case PROP_ACTIVE:
|
||||
g_value_set_boolean (value, priv->is_checked);
|
||||
break;
|
||||
case PROP_TRANSITION_DURATION:
|
||||
case PROP_TRANSITION:
|
||||
g_value_set_int (value, priv->transition_duration);
|
||||
break;
|
||||
|
||||
@ -385,86 +382,86 @@ st_button_get_property (GObject *gobject,
|
||||
}
|
||||
|
||||
static void
|
||||
st_button_finalize (GObject *gobject)
|
||||
nbtk_button_finalize (GObject *gobject)
|
||||
{
|
||||
StButtonPrivate *priv = ST_BUTTON (gobject)->priv;
|
||||
NbtkButtonPrivate *priv = NBTK_BUTTON (gobject)->priv;
|
||||
|
||||
g_free (priv->text);
|
||||
|
||||
G_OBJECT_CLASS (st_button_parent_class)->finalize (gobject);
|
||||
G_OBJECT_CLASS (nbtk_button_parent_class)->finalize (gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
st_button_dispose (GObject *gobject)
|
||||
nbtk_button_dispose (GObject *gobject)
|
||||
{
|
||||
st_button_dispose_old_bg (ST_BUTTON (gobject));
|
||||
nbtk_button_dispose_old_bg (NBTK_BUTTON (gobject));
|
||||
|
||||
G_OBJECT_CLASS (st_button_parent_class)->dispose (gobject);
|
||||
G_OBJECT_CLASS (nbtk_button_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
st_button_map (ClutterActor *self)
|
||||
nbtk_button_map (ClutterActor *self)
|
||||
{
|
||||
StButtonPrivate *priv = ST_BUTTON (self)->priv;
|
||||
NbtkButtonPrivate *priv = NBTK_BUTTON (self)->priv;
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_button_parent_class)->map (self);
|
||||
CLUTTER_ACTOR_CLASS (nbtk_button_parent_class)->map (self);
|
||||
|
||||
if (priv->old_bg && priv->old_bg_parented)
|
||||
clutter_actor_map (priv->old_bg);
|
||||
}
|
||||
|
||||
static void
|
||||
st_button_unmap (ClutterActor *self)
|
||||
nbtk_button_unmap (ClutterActor *self)
|
||||
{
|
||||
StButtonPrivate *priv = ST_BUTTON (self)->priv;
|
||||
NbtkButtonPrivate *priv = NBTK_BUTTON (self)->priv;
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_button_parent_class)->unmap (self);
|
||||
CLUTTER_ACTOR_CLASS (nbtk_button_parent_class)->unmap (self);
|
||||
|
||||
if (priv->old_bg && priv->old_bg_parented)
|
||||
clutter_actor_unmap (priv->old_bg);
|
||||
}
|
||||
|
||||
static void
|
||||
st_button_draw_background (StWidget *widget)
|
||||
nbtk_button_draw_background (NbtkWidget *widget)
|
||||
{
|
||||
StButtonPrivate *priv;
|
||||
NbtkButtonPrivate *priv;
|
||||
|
||||
ST_WIDGET_CLASS (st_button_parent_class)->draw_background (widget);
|
||||
NBTK_WIDGET_CLASS (nbtk_button_parent_class)->draw_background (widget);
|
||||
|
||||
priv = ST_BUTTON (widget)->priv;
|
||||
priv = NBTK_BUTTON (widget)->priv;
|
||||
|
||||
if (priv->old_bg && priv->old_bg_parented)
|
||||
clutter_actor_paint (priv->old_bg);
|
||||
clutter_actor_paint (priv->old_bg);
|
||||
}
|
||||
|
||||
static void
|
||||
st_button_class_init (StButtonClass *klass)
|
||||
nbtk_button_class_init (NbtkButtonClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
||||
StWidgetClass *widget_class = ST_WIDGET_CLASS (klass);
|
||||
NbtkWidgetClass *widget_class = NBTK_WIDGET_CLASS (klass);
|
||||
GParamSpec *pspec;
|
||||
|
||||
g_type_class_add_private (klass, sizeof (StButtonPrivate));
|
||||
g_type_class_add_private (klass, sizeof (NbtkButtonPrivate));
|
||||
|
||||
klass->pressed = st_button_real_pressed;
|
||||
klass->released = st_button_real_released;
|
||||
klass->pressed = nbtk_button_real_pressed;
|
||||
klass->released = nbtk_button_real_released;
|
||||
|
||||
gobject_class->set_property = st_button_set_property;
|
||||
gobject_class->get_property = st_button_get_property;
|
||||
gobject_class->dispose = st_button_dispose;
|
||||
gobject_class->finalize = st_button_finalize;
|
||||
gobject_class->set_property = nbtk_button_set_property;
|
||||
gobject_class->get_property = nbtk_button_get_property;
|
||||
gobject_class->dispose = nbtk_button_dispose;
|
||||
gobject_class->finalize = nbtk_button_finalize;
|
||||
|
||||
actor_class->button_press_event = st_button_button_press;
|
||||
actor_class->button_release_event = st_button_button_release;
|
||||
actor_class->enter_event = st_button_enter;
|
||||
actor_class->leave_event = st_button_leave;
|
||||
actor_class->button_press_event = nbtk_button_button_press;
|
||||
actor_class->button_release_event = nbtk_button_button_release;
|
||||
actor_class->enter_event = nbtk_button_enter;
|
||||
actor_class->leave_event = nbtk_button_leave;
|
||||
|
||||
actor_class->map = st_button_map;
|
||||
actor_class->unmap = st_button_unmap;
|
||||
actor_class->map = nbtk_button_map;
|
||||
actor_class->unmap = nbtk_button_unmap;
|
||||
|
||||
widget_class->draw_background = st_button_draw_background;
|
||||
widget_class->style_changed = st_button_style_changed;
|
||||
widget_class->draw_background = nbtk_button_draw_background;
|
||||
widget_class->style_changed = nbtk_button_style_changed;
|
||||
|
||||
pspec = g_param_spec_string ("label",
|
||||
"Label",
|
||||
@ -476,24 +473,24 @@ st_button_class_init (StButtonClass *klass)
|
||||
"Toggle Mode",
|
||||
"Enable or disable toggling",
|
||||
FALSE, G_PARAM_READWRITE);
|
||||
g_object_class_install_property (gobject_class, PROP_TOGGLE_MODE, pspec);
|
||||
g_object_class_install_property (gobject_class, PROP_TOGGLE, pspec);
|
||||
|
||||
pspec = g_param_spec_boolean ("checked",
|
||||
"Checked",
|
||||
"Indicates if a toggle button is \"on\""
|
||||
" or \"off\"",
|
||||
FALSE, G_PARAM_READWRITE);
|
||||
g_object_class_install_property (gobject_class, PROP_CHECKED, pspec);
|
||||
g_object_class_install_property (gobject_class, PROP_ACTIVE, pspec);
|
||||
|
||||
pspec = g_param_spec_int ("transition-duration",
|
||||
"Transition Duration",
|
||||
"Duration of the state transition effect",
|
||||
0, G_MAXINT, 120, G_PARAM_READWRITE);
|
||||
g_object_class_install_property (gobject_class, PROP_TRANSITION_DURATION, pspec);
|
||||
g_object_class_install_property (gobject_class, PROP_TRANSITION, pspec);
|
||||
|
||||
|
||||
/**
|
||||
* StButton::clicked:
|
||||
* NbtkButton::clicked:
|
||||
* @button: the object that received the signal
|
||||
*
|
||||
* Emitted when the user activates the button, either with a mouse press and
|
||||
@ -504,16 +501,16 @@ st_button_class_init (StButtonClass *klass)
|
||||
g_signal_new ("clicked",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (StButtonClass, clicked),
|
||||
G_STRUCT_OFFSET (NbtkButtonClass, clicked),
|
||||
NULL, NULL,
|
||||
_st_marshal_VOID__VOID,
|
||||
_nbtk_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
st_button_init (StButton *button)
|
||||
nbtk_button_init (NbtkButton *button)
|
||||
{
|
||||
button->priv = ST_BUTTON_GET_PRIVATE (button);
|
||||
button->priv = NBTK_BUTTON_GET_PRIVATE (button);
|
||||
button->priv->transition_duration = 120;
|
||||
button->priv->spacing = 6;
|
||||
|
||||
@ -521,63 +518,63 @@ st_button_init (StButton *button)
|
||||
}
|
||||
|
||||
/**
|
||||
* st_button_new:
|
||||
* nbtk_button_new:
|
||||
*
|
||||
* Create a new button
|
||||
*
|
||||
* Returns: a new #StButton
|
||||
* Returns: a new #NbtkButton
|
||||
*/
|
||||
StWidget *
|
||||
st_button_new (void)
|
||||
NbtkWidget *
|
||||
nbtk_button_new (void)
|
||||
{
|
||||
return g_object_new (ST_TYPE_BUTTON, NULL);
|
||||
return g_object_new (NBTK_TYPE_BUTTON, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_button_new_with_label:
|
||||
* nbtk_button_new_with_label:
|
||||
* @text: text to set the label to
|
||||
*
|
||||
* Create a new #StButton with the specified label
|
||||
* Create a new #NbtkButton with the specified label
|
||||
*
|
||||
* Returns: a new #StButton
|
||||
* Returns: a new #NbtkButton
|
||||
*/
|
||||
StWidget *
|
||||
st_button_new_with_label (const gchar *text)
|
||||
NbtkWidget *
|
||||
nbtk_button_new_with_label (const gchar *text)
|
||||
{
|
||||
return g_object_new (ST_TYPE_BUTTON, "label", text, NULL);
|
||||
return g_object_new (NBTK_TYPE_BUTTON, "label", text, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_button_get_label:
|
||||
* @button: a #StButton
|
||||
* nbtk_button_get_label:
|
||||
* @button: a #NbtkButton
|
||||
*
|
||||
* Get the text displayed on the button
|
||||
*
|
||||
* Returns: the text for the button. This must not be freed by the application
|
||||
*/
|
||||
G_CONST_RETURN gchar *
|
||||
st_button_get_label (StButton *button)
|
||||
nbtk_button_get_label (NbtkButton *button)
|
||||
{
|
||||
g_return_val_if_fail (ST_IS_BUTTON (button), NULL);
|
||||
g_return_val_if_fail (NBTK_IS_BUTTON (button), NULL);
|
||||
|
||||
return button->priv->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* st_button_set_label:
|
||||
* @button: a #Stbutton
|
||||
* nbtk_button_set_label:
|
||||
* @button: a #Nbtkbutton
|
||||
* @text: text to set the label to
|
||||
*
|
||||
* Sets the text displayed on the button
|
||||
*/
|
||||
void
|
||||
st_button_set_label (StButton *button,
|
||||
const gchar *text)
|
||||
nbtk_button_set_label (NbtkButton *button,
|
||||
const gchar *text)
|
||||
{
|
||||
StButtonPrivate *priv;
|
||||
NbtkButtonPrivate *priv;
|
||||
ClutterActor *label;
|
||||
|
||||
g_return_if_fail (ST_IS_BUTTON (button));
|
||||
g_return_if_fail (NBTK_IS_BUTTON (button));
|
||||
|
||||
priv = button->priv;
|
||||
|
||||
@ -588,7 +585,7 @@ st_button_set_label (StButton *button,
|
||||
else
|
||||
priv->text = g_strdup ("");
|
||||
|
||||
label = st_bin_get_child ((StBin*) button);
|
||||
label = nbtk_bin_get_child ((NbtkBin*) button);
|
||||
|
||||
if (label && CLUTTER_IS_TEXT (label))
|
||||
{
|
||||
@ -602,44 +599,44 @@ st_button_set_label (StButton *button,
|
||||
"ellipsize", PANGO_ELLIPSIZE_END,
|
||||
"use-markup", TRUE,
|
||||
NULL);
|
||||
st_bin_set_child ((StBin*) button, label);
|
||||
nbtk_bin_set_child ((NbtkBin*) button, label);
|
||||
}
|
||||
|
||||
/* Fake a style change so that we reset the style properties on the label */
|
||||
st_widget_style_changed (ST_WIDGET (button));
|
||||
nbtk_widget_style_changed (NBTK_WIDGET (button));
|
||||
|
||||
g_object_notify (G_OBJECT (button), "label");
|
||||
}
|
||||
|
||||
/**
|
||||
* st_button_get_toggle_mode:
|
||||
* @button: a #StButton
|
||||
* nbtk_button_get_toggle_mode:
|
||||
* @button: a #NbtkButton
|
||||
*
|
||||
* Get the toggle mode status of the button.
|
||||
*
|
||||
* Returns: #TRUE if toggle mode is set, otherwise #FALSE
|
||||
*/
|
||||
gboolean
|
||||
st_button_get_toggle_mode (StButton *button)
|
||||
nbtk_button_get_toggle_mode (NbtkButton *button)
|
||||
{
|
||||
g_return_val_if_fail (ST_IS_BUTTON (button), FALSE);
|
||||
g_return_val_if_fail (NBTK_IS_BUTTON (button), FALSE);
|
||||
|
||||
return button->priv->is_toggle;
|
||||
}
|
||||
|
||||
/**
|
||||
* st_button_set_toggle_mode:
|
||||
* @button: a #Stbutton
|
||||
* nbtk_button_set_toggle_mode:
|
||||
* @button: a #Nbtkbutton
|
||||
* @toggle: #TRUE or #FALSE
|
||||
*
|
||||
* Enables or disables toggle mode for the button. In toggle mode, the active
|
||||
* state will be "toggled" when the user clicks the button.
|
||||
*/
|
||||
void
|
||||
st_button_set_toggle_mode (StButton *button,
|
||||
gboolean toggle)
|
||||
nbtk_button_set_toggle_mode (NbtkButton *button,
|
||||
gboolean toggle)
|
||||
{
|
||||
g_return_if_fail (ST_IS_BUTTON (button));
|
||||
g_return_if_fail (NBTK_IS_BUTTON (button));
|
||||
|
||||
button->priv->is_toggle = toggle;
|
||||
|
||||
@ -647,46 +644,46 @@ st_button_set_toggle_mode (StButton *button,
|
||||
}
|
||||
|
||||
/**
|
||||
* st_button_get_checked:
|
||||
* @button: a #StButton
|
||||
* nbtk_button_get_checked:
|
||||
* @button: a #NbtkButton
|
||||
*
|
||||
* Get the state of the button that is in toggle mode.
|
||||
*
|
||||
* Returns: #TRUE if the button is checked, or #FALSE if not
|
||||
*/
|
||||
gboolean
|
||||
st_button_get_checked (StButton *button)
|
||||
nbtk_button_get_checked (NbtkButton *button)
|
||||
{
|
||||
g_return_val_if_fail (ST_IS_BUTTON (button), FALSE);
|
||||
g_return_val_if_fail (NBTK_IS_BUTTON (button), FALSE);
|
||||
|
||||
return button->priv->is_checked;
|
||||
}
|
||||
|
||||
/**
|
||||
* st_button_set_checked:
|
||||
* @button: a #Stbutton
|
||||
* nbtk_button_set_checked:
|
||||
* @button: a #Nbtkbutton
|
||||
* @checked: #TRUE or #FALSE
|
||||
*
|
||||
* Sets the pressed state of the button. This is only really useful if the
|
||||
* button has #toggle-mode mode set to #TRUE.
|
||||
*/
|
||||
void
|
||||
st_button_set_checked (StButton *button,
|
||||
gboolean checked)
|
||||
nbtk_button_set_checked (NbtkButton *button,
|
||||
gboolean checked)
|
||||
{
|
||||
g_return_if_fail (ST_IS_BUTTON (button));
|
||||
g_return_if_fail (NBTK_IS_BUTTON (button));
|
||||
|
||||
if (button->priv->is_checked != checked)
|
||||
{
|
||||
button->priv->is_checked = checked;
|
||||
|
||||
if (checked)
|
||||
st_widget_set_style_pseudo_class ((StWidget*) button, "checked");
|
||||
nbtk_widget_set_style_pseudo_class ((NbtkWidget*) button, "checked");
|
||||
else
|
||||
if (button->priv->is_hover)
|
||||
st_widget_set_style_pseudo_class ((StWidget*) button, "hover");
|
||||
else
|
||||
st_widget_set_style_pseudo_class ((StWidget*) button, NULL);
|
||||
if (button->priv->is_hover)
|
||||
nbtk_widget_set_style_pseudo_class ((NbtkWidget*) button, "hover");
|
||||
else
|
||||
nbtk_widget_set_style_pseudo_class ((NbtkWidget*) button, NULL);
|
||||
}
|
||||
|
||||
g_object_notify (G_OBJECT (button), "checked");
|
90
src/nbtk/nbtk-button.h
Normal file
90
src/nbtk/nbtk-button.h
Normal file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* nbtk-button.h: Plain button actor
|
||||
*
|
||||
* Copyright 2007 OpenedHand
|
||||
* Copyright 2008, 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Written by: Emmanuele Bassi <ebassi@openedhand.com>
|
||||
* Thomas Wood <thomas@linux.intel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(NBTK_H_INSIDE) && !defined(NBTK_COMPILATION)
|
||||
#error "Only <nbtk/nbtk.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef __NBTK_BUTTON_H__
|
||||
#define __NBTK_BUTTON_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#include <nbtk/nbtk-bin.h>
|
||||
|
||||
#define NBTK_TYPE_BUTTON (nbtk_button_get_type ())
|
||||
#define NBTK_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NBTK_TYPE_BUTTON, NbtkButton))
|
||||
#define NBTK_IS_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NBTK_TYPE_BUTTON))
|
||||
#define NBTK_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NBTK_TYPE_BUTTON, NbtkButtonClass))
|
||||
#define NBTK_IS_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NBTK_TYPE_BUTTON))
|
||||
#define NBTK_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NBTK_TYPE_BUTTON, NbtkButtonClass))
|
||||
|
||||
typedef struct _NbtkButton NbtkButton;
|
||||
typedef struct _NbtkButtonPrivate NbtkButtonPrivate;
|
||||
typedef struct _NbtkButtonClass NbtkButtonClass;
|
||||
|
||||
/**
|
||||
* NbtkButton:
|
||||
*
|
||||
* The contents of this structure is private and should only be accessed using
|
||||
* the provided API.
|
||||
*/
|
||||
|
||||
struct _NbtkButton
|
||||
{
|
||||
/*< private >*/
|
||||
NbtkBin parent_instance;
|
||||
|
||||
NbtkButtonPrivate *priv;
|
||||
};
|
||||
|
||||
struct _NbtkButtonClass
|
||||
{
|
||||
NbtkBinClass parent_class;
|
||||
|
||||
/* vfuncs, not signals */
|
||||
void (* pressed) (NbtkButton *button);
|
||||
void (* released) (NbtkButton *button);
|
||||
void (* transition) (NbtkButton *button, ClutterActor *old_bg);
|
||||
|
||||
/* signals */
|
||||
void (* clicked) (NbtkButton *button);
|
||||
};
|
||||
|
||||
GType nbtk_button_get_type (void) G_GNUC_CONST;
|
||||
|
||||
NbtkWidget * nbtk_button_new (void);
|
||||
NbtkWidget * nbtk_button_new_with_label (const gchar *text);
|
||||
G_CONST_RETURN gchar *nbtk_button_get_label (NbtkButton *button);
|
||||
void nbtk_button_set_label (NbtkButton *button,
|
||||
const gchar *text);
|
||||
void nbtk_button_set_toggle_mode (NbtkButton *button, gboolean toggle);
|
||||
gboolean nbtk_button_get_toggle_mode (NbtkButton *button);
|
||||
void nbtk_button_set_checked (NbtkButton *button, gboolean checked);
|
||||
gboolean nbtk_button_get_checked (NbtkButton *button);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NBTK_BUTTON_H__ */
|
@ -1,6 +1,5 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-clipboard.c: clipboard object
|
||||
* nbtk-clipboard.c: clipboard object
|
||||
*
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
@ -21,42 +20,33 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:st-clipboard
|
||||
* @short_description: a simple representation of the X clipboard
|
||||
*
|
||||
* #StCliboard is a very simple object representation of the clipboard
|
||||
* available to applications. Text is always assumed to be UTF-8 and non-text
|
||||
* items are not handled.
|
||||
*/
|
||||
|
||||
|
||||
#include "st-clipboard.h"
|
||||
#include "nbtk-clipboard.h"
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <clutter/x11/clutter-x11.h>
|
||||
#include <string.h>
|
||||
|
||||
G_DEFINE_TYPE (StClipboard, st_clipboard, G_TYPE_OBJECT)
|
||||
G_DEFINE_TYPE (NbtkClipboard, nbtk_clipboard, G_TYPE_OBJECT)
|
||||
|
||||
#define CLIPBOARD_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), ST_TYPE_CLIPBOARD, StClipboardPrivate))
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), NBTK_TYPE_CLIPBOARD, NbtkClipboardPrivate))
|
||||
|
||||
struct _StClipboardPrivate
|
||||
struct _NbtkClipboardPrivate
|
||||
{
|
||||
Window clipboard_window;
|
||||
gchar *clipboard_text;
|
||||
|
||||
Atom *supported_targets;
|
||||
gint n_targets;
|
||||
Atom *supported_targets;
|
||||
gint n_targets;
|
||||
};
|
||||
|
||||
typedef struct _EventFilterData EventFilterData;
|
||||
struct _EventFilterData
|
||||
{
|
||||
StClipboard *clipboard;
|
||||
StClipboardCallbackFunc callback;
|
||||
gpointer user_data;
|
||||
NbtkClipboard *clipboard;
|
||||
NbtkClipboardCallbackFunc callback;
|
||||
gpointer user_data;
|
||||
};
|
||||
|
||||
static Atom __atom_clip = None;
|
||||
@ -64,10 +54,8 @@ static Atom __utf8_string = None;
|
||||
static Atom __atom_targets = None;
|
||||
|
||||
static void
|
||||
st_clipboard_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
nbtk_clipboard_get_property (GObject *object, guint property_id,
|
||||
GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
switch (property_id)
|
||||
{
|
||||
@ -77,10 +65,8 @@ st_clipboard_get_property (GObject *object,
|
||||
}
|
||||
|
||||
static void
|
||||
st_clipboard_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
nbtk_clipboard_set_property (GObject *object, guint property_id,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
switch (property_id)
|
||||
{
|
||||
@ -90,15 +76,15 @@ st_clipboard_set_property (GObject *object,
|
||||
}
|
||||
|
||||
static void
|
||||
st_clipboard_dispose (GObject *object)
|
||||
nbtk_clipboard_dispose (GObject *object)
|
||||
{
|
||||
G_OBJECT_CLASS (st_clipboard_parent_class)->dispose (object);
|
||||
G_OBJECT_CLASS (nbtk_clipboard_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
st_clipboard_finalize (GObject *object)
|
||||
nbtk_clipboard_finalize (GObject *object)
|
||||
{
|
||||
StClipboardPrivate *priv = ((StClipboard *) object)->priv;
|
||||
NbtkClipboardPrivate *priv = ((NbtkClipboard *) object)->priv;
|
||||
|
||||
g_free (priv->clipboard_text);
|
||||
priv->clipboard_text = NULL;
|
||||
@ -107,13 +93,13 @@ st_clipboard_finalize (GObject *object)
|
||||
priv->supported_targets = NULL;
|
||||
priv->n_targets = 0;
|
||||
|
||||
G_OBJECT_CLASS (st_clipboard_parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (nbtk_clipboard_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static ClutterX11FilterReturn
|
||||
st_clipboard_provider (XEvent *xev,
|
||||
ClutterEvent *cev,
|
||||
StClipboard *clipboard)
|
||||
nbtk_clipboard_provider (XEvent *xev,
|
||||
ClutterEvent *cev,
|
||||
NbtkClipboard *clipboard)
|
||||
{
|
||||
XSelectionEvent notify_event;
|
||||
XSelectionRequestEvent *req_event;
|
||||
@ -173,23 +159,23 @@ st_clipboard_provider (XEvent *xev,
|
||||
|
||||
|
||||
static void
|
||||
st_clipboard_class_init (StClipboardClass *klass)
|
||||
nbtk_clipboard_class_init (NbtkClipboardClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
g_type_class_add_private (klass, sizeof (StClipboardPrivate));
|
||||
g_type_class_add_private (klass, sizeof (NbtkClipboardPrivate));
|
||||
|
||||
object_class->get_property = st_clipboard_get_property;
|
||||
object_class->set_property = st_clipboard_set_property;
|
||||
object_class->dispose = st_clipboard_dispose;
|
||||
object_class->finalize = st_clipboard_finalize;
|
||||
object_class->get_property = nbtk_clipboard_get_property;
|
||||
object_class->set_property = nbtk_clipboard_set_property;
|
||||
object_class->dispose = nbtk_clipboard_dispose;
|
||||
object_class->finalize = nbtk_clipboard_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
st_clipboard_init (StClipboard *self)
|
||||
nbtk_clipboard_init (NbtkClipboard *self)
|
||||
{
|
||||
Display *dpy;
|
||||
StClipboardPrivate *priv;
|
||||
NbtkClipboardPrivate *priv;
|
||||
|
||||
priv = self->priv = CLIPBOARD_PRIVATE (self);
|
||||
|
||||
@ -216,14 +202,14 @@ st_clipboard_init (StClipboard *self)
|
||||
priv->supported_targets[0] = __utf8_string;
|
||||
priv->supported_targets[1] = __atom_targets;
|
||||
|
||||
clutter_x11_add_filter ((ClutterX11FilterFunc) st_clipboard_provider,
|
||||
clutter_x11_add_filter ((ClutterX11FilterFunc) nbtk_clipboard_provider,
|
||||
self);
|
||||
}
|
||||
|
||||
static ClutterX11FilterReturn
|
||||
st_clipboard_x11_event_filter (XEvent *xev,
|
||||
ClutterEvent *cev,
|
||||
EventFilterData *filter_data)
|
||||
nbtk_clipboard_x11_event_filter (XEvent *xev,
|
||||
ClutterEvent *cev,
|
||||
EventFilterData *filter_data)
|
||||
{
|
||||
Atom actual_type;
|
||||
int actual_format, result;
|
||||
@ -240,7 +226,7 @@ st_clipboard_x11_event_filter (XEvent *xev,
|
||||
NULL,
|
||||
filter_data->user_data);
|
||||
|
||||
clutter_x11_remove_filter ((ClutterX11FilterFunc) st_clipboard_x11_event_filter,
|
||||
clutter_x11_remove_filter ((ClutterX11FilterFunc) nbtk_clipboard_x11_event_filter,
|
||||
filter_data);
|
||||
g_free (filter_data);
|
||||
return CLUTTER_X11_FILTER_REMOVE;
|
||||
@ -270,8 +256,8 @@ st_clipboard_x11_event_filter (XEvent *xev,
|
||||
filter_data->user_data);
|
||||
|
||||
clutter_x11_remove_filter
|
||||
((ClutterX11FilterFunc) st_clipboard_x11_event_filter,
|
||||
filter_data);
|
||||
((ClutterX11FilterFunc) nbtk_clipboard_x11_event_filter,
|
||||
filter_data);
|
||||
|
||||
g_free (filter_data);
|
||||
|
||||
@ -282,29 +268,29 @@ st_clipboard_x11_event_filter (XEvent *xev,
|
||||
}
|
||||
|
||||
/**
|
||||
* st_clipboard_get_default:
|
||||
* nbtk_clipboard_get_default:
|
||||
*
|
||||
* Get the global #StClipboard object that represents the clipboard.
|
||||
* Get the global #NbtkClipboard object that represents the clipboard.
|
||||
*
|
||||
* Returns: (transfer none): a #StClipboard owned by St and must not be
|
||||
* Returns: (transfer none): a #NbtkClipboard owned by Nbtk and must not be
|
||||
* unrefferenced or freed.
|
||||
*/
|
||||
StClipboard*
|
||||
st_clipboard_get_default (void)
|
||||
NbtkClipboard*
|
||||
nbtk_clipboard_get_default (void)
|
||||
{
|
||||
static StClipboard *default_clipboard = NULL;
|
||||
static NbtkClipboard *default_clipboard = NULL;
|
||||
|
||||
if (!default_clipboard)
|
||||
{
|
||||
default_clipboard = g_object_new (ST_TYPE_CLIPBOARD, NULL);
|
||||
default_clipboard = g_object_new (NBTK_TYPE_CLIPBOARD, NULL);
|
||||
}
|
||||
|
||||
return default_clipboard;
|
||||
}
|
||||
|
||||
/**
|
||||
* st_clipboard_get_text:
|
||||
* @clipboard: A #StCliboard
|
||||
* nbtk_clipboard_get_text:
|
||||
* @clipboard: A #NbtkCliboard
|
||||
* @callback: function to be called when the text is retreived
|
||||
* @user_data: data to be passed to the callback
|
||||
*
|
||||
@ -313,15 +299,15 @@ st_clipboard_get_default (void)
|
||||
*
|
||||
*/
|
||||
void
|
||||
st_clipboard_get_text (StClipboard *clipboard,
|
||||
StClipboardCallbackFunc callback,
|
||||
gpointer user_data)
|
||||
nbtk_clipboard_get_text (NbtkClipboard *clipboard,
|
||||
NbtkClipboardCallbackFunc callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
EventFilterData *data;
|
||||
|
||||
Display *dpy;
|
||||
|
||||
g_return_if_fail (ST_IS_CLIPBOARD (clipboard));
|
||||
g_return_if_fail (NBTK_IS_CLIPBOARD (clipboard));
|
||||
g_return_if_fail (callback != NULL);
|
||||
|
||||
data = g_new0 (EventFilterData, 1);
|
||||
@ -329,7 +315,7 @@ st_clipboard_get_text (StClipboard *clipboard,
|
||||
data->callback = callback;
|
||||
data->user_data = user_data;
|
||||
|
||||
clutter_x11_add_filter ((ClutterX11FilterFunc) st_clipboard_x11_event_filter,
|
||||
clutter_x11_add_filter ((ClutterX11FilterFunc)nbtk_clipboard_x11_event_filter,
|
||||
data);
|
||||
|
||||
dpy = clutter_x11_get_default_display ();
|
||||
@ -346,21 +332,21 @@ st_clipboard_get_text (StClipboard *clipboard,
|
||||
}
|
||||
|
||||
/**
|
||||
* st_clipboard_set_text:
|
||||
* @clipboard: A #StClipboard
|
||||
* nbtk_clipboard_set_text:
|
||||
* @clipboard: A #NbtkClipboard
|
||||
* @text: text to copy to the clipboard
|
||||
*
|
||||
* Sets text as the current contents of the clipboard.
|
||||
*
|
||||
*/
|
||||
void
|
||||
st_clipboard_set_text (StClipboard *clipboard,
|
||||
const gchar *text)
|
||||
nbtk_clipboard_set_text (NbtkClipboard *clipboard,
|
||||
const gchar *text)
|
||||
{
|
||||
StClipboardPrivate *priv;
|
||||
NbtkClipboardPrivate *priv;
|
||||
Display *dpy;
|
||||
|
||||
g_return_if_fail (ST_IS_CLIPBOARD (clipboard));
|
||||
g_return_if_fail (NBTK_IS_CLIPBOARD (clipboard));
|
||||
g_return_if_fail (text != NULL);
|
||||
|
||||
priv = clipboard->priv;
|
94
src/nbtk/nbtk-clipboard.h
Normal file
94
src/nbtk/nbtk-clipboard.h
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* nbtk-clipboard.h: clipboard object
|
||||
*
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Written by: Thomas Wood <thomas.wood@intel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _NBTK_CLIPBOARD_H
|
||||
#define _NBTK_CLIPBOARD_H
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NBTK_TYPE_CLIPBOARD nbtk_clipboard_get_type()
|
||||
|
||||
#define NBTK_CLIPBOARD(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
||||
NBTK_TYPE_CLIPBOARD, NbtkClipboard))
|
||||
|
||||
#define NBTK_CLIPBOARD_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), \
|
||||
NBTK_TYPE_CLIPBOARD, NbtkClipboardClass))
|
||||
|
||||
#define NBTK_IS_CLIPBOARD(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
|
||||
NBTK_TYPE_CLIPBOARD))
|
||||
|
||||
#define NBTK_IS_CLIPBOARD_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
|
||||
NBTK_TYPE_CLIPBOARD))
|
||||
|
||||
#define NBTK_CLIPBOARD_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
|
||||
NBTK_TYPE_CLIPBOARD, NbtkClipboardClass))
|
||||
|
||||
typedef struct _NbtkClipboard NbtkClipboard;
|
||||
typedef struct _NbtkClipboardClass NbtkClipboardClass;
|
||||
typedef struct _NbtkClipboardPrivate NbtkClipboardPrivate;
|
||||
|
||||
/**
|
||||
* NbtkClipboard:
|
||||
*
|
||||
* The contents of this structure is private and should only be accessed using
|
||||
* the provided API.
|
||||
*/
|
||||
struct _NbtkClipboard
|
||||
{
|
||||
/*< private >*/
|
||||
GObject parent;
|
||||
NbtkClipboardPrivate *priv;
|
||||
};
|
||||
|
||||
struct _NbtkClipboardClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
/**
|
||||
* NbtkClipboardCallbackFunc:
|
||||
* @clipboard: A #NbtkClipboard
|
||||
* @text: text from the clipboard
|
||||
* @user_data: user data
|
||||
*
|
||||
* Callback function called when text is retrieved from the clipboard.
|
||||
*/
|
||||
typedef void (*NbtkClipboardCallbackFunc) (NbtkClipboard *clipboard,
|
||||
const gchar *text,
|
||||
gpointer user_data);
|
||||
|
||||
GType nbtk_clipboard_get_type (void);
|
||||
|
||||
NbtkClipboard* nbtk_clipboard_get_default (void);
|
||||
void nbtk_clipboard_get_text (NbtkClipboard *clipboard, NbtkClipboardCallbackFunc callback, gpointer user_data);
|
||||
void nbtk_clipboard_set_text (NbtkClipboard *clipboard, const gchar *text);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _NBTK_CLIPBOARD_H */
|
@ -1,6 +1,5 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-entry.c: Plain entry actor
|
||||
* nbtk-entry.c: Plain entry actor
|
||||
*
|
||||
* Copyright 2008, 2009 Intel Corporation
|
||||
*
|
||||
@ -22,15 +21,15 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:st-entry
|
||||
* SECTION:nbtk-entry
|
||||
* @short_description: Widget for displaying text
|
||||
*
|
||||
* #StEntry is a simple widget for displaying text. It derives from
|
||||
* #StWidget to add extra style and placement functionality over
|
||||
* #NbtkEntry is a simple widget for displaying text. It derives from
|
||||
* #NbtkWidget to add extra style and placement functionality over
|
||||
* #ClutterText. The internal #ClutterText is publicly accessibly to allow
|
||||
* applications to set further properties.
|
||||
*
|
||||
* #StEntry supports the following pseudo style states:
|
||||
* #NbtkEntry supports the following pseudo style states:
|
||||
* <itemizedlist>
|
||||
* <listitem>
|
||||
* <para>focus: the widget has focus</para>
|
||||
@ -55,12 +54,12 @@
|
||||
#include <clutter/clutter.h>
|
||||
#include <clutter-imcontext/clutter-imtext.h>
|
||||
|
||||
#include "st-entry.h"
|
||||
#include "nbtk-entry.h"
|
||||
|
||||
#include "st-widget.h"
|
||||
#include "st-texture-cache.h"
|
||||
#include "st-marshal.h"
|
||||
#include "st-clipboard.h"
|
||||
#include "nbtk-widget.h"
|
||||
#include "nbtk-texture-cache.h"
|
||||
#include "nbtk-marshal.h"
|
||||
#include "nbtk-clipboard.h"
|
||||
|
||||
#define HAS_FOCUS(actor) (clutter_actor_get_stage (actor) && clutter_stage_get_key_focus ((ClutterStage *) clutter_actor_get_stage (actor)) == actor)
|
||||
|
||||
@ -84,11 +83,11 @@ enum
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
#define ST_ENTRY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ST_TYPE_ENTRY, StEntryPrivate))
|
||||
#define ST_ENTRY_PRIV(x) ((StEntry *) x)->priv
|
||||
#define NBTK_ENTRY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), NBTK_TYPE_ENTRY, NbtkEntryPrivate))
|
||||
#define NBTK_ENTRY_PRIV(x) ((NbtkEntry *) x)->priv
|
||||
|
||||
|
||||
struct _StEntryPrivate
|
||||
struct _NbtkEntryPrivate
|
||||
{
|
||||
ClutterActor *entry;
|
||||
gchar *hint;
|
||||
@ -96,29 +95,29 @@ struct _StEntryPrivate
|
||||
ClutterActor *primary_icon;
|
||||
ClutterActor *secondary_icon;
|
||||
|
||||
gfloat spacing;
|
||||
gfloat spacing;
|
||||
};
|
||||
|
||||
static guint entry_signals[LAST_SIGNAL] = { 0, };
|
||||
|
||||
G_DEFINE_TYPE (StEntry, st_entry, ST_TYPE_WIDGET);
|
||||
G_DEFINE_TYPE (NbtkEntry, nbtk_entry, NBTK_TYPE_WIDGET);
|
||||
|
||||
static void
|
||||
st_entry_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
nbtk_entry_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StEntry *entry = ST_ENTRY (gobject);
|
||||
NbtkEntry *entry = NBTK_ENTRY (gobject);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_HINT_TEXT:
|
||||
st_entry_set_hint_text (entry, g_value_get_string (value));
|
||||
nbtk_entry_set_hint_text (entry, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
case PROP_TEXT:
|
||||
st_entry_set_text (entry, g_value_get_string (value));
|
||||
nbtk_entry_set_text (entry, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -128,12 +127,12 @@ st_entry_set_property (GObject *gobject,
|
||||
}
|
||||
|
||||
static void
|
||||
st_entry_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
nbtk_entry_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StEntryPrivate *priv = ST_ENTRY_PRIV (gobject);
|
||||
NbtkEntryPrivate *priv = NBTK_ENTRY_PRIV (gobject);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
@ -156,9 +155,9 @@ st_entry_get_property (GObject *gobject,
|
||||
}
|
||||
|
||||
static void
|
||||
st_entry_dispose (GObject *object)
|
||||
nbtk_entry_dispose (GObject *object)
|
||||
{
|
||||
StEntryPrivate *priv = ST_ENTRY_PRIV (object);
|
||||
NbtkEntryPrivate *priv = NBTK_ENTRY_PRIV (object);
|
||||
|
||||
if (priv->entry)
|
||||
{
|
||||
@ -168,53 +167,53 @@ st_entry_dispose (GObject *object)
|
||||
}
|
||||
|
||||
static void
|
||||
st_entry_finalize (GObject *object)
|
||||
nbtk_entry_finalize (GObject *object)
|
||||
{
|
||||
StEntryPrivate *priv = ST_ENTRY_PRIV (object);
|
||||
NbtkEntryPrivate *priv = NBTK_ENTRY_PRIV (object);
|
||||
|
||||
g_free (priv->hint);
|
||||
priv->hint = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
st_entry_style_changed (StWidget *self)
|
||||
nbtk_entry_style_changed (NbtkWidget *self)
|
||||
{
|
||||
StEntryPrivate *priv = ST_ENTRY_PRIV (self);
|
||||
StThemeNode *theme_node;
|
||||
NbtkEntryPrivate *priv = NBTK_ENTRY_PRIV (self);
|
||||
ShellThemeNode *theme_node;
|
||||
ClutterColor color;
|
||||
const PangoFontDescription *font;
|
||||
gchar *font_string;
|
||||
|
||||
theme_node = st_widget_get_theme_node (self);
|
||||
|
||||
st_theme_node_get_foreground_color (theme_node, &color);
|
||||
theme_node = nbtk_widget_get_theme_node (self);
|
||||
|
||||
shell_theme_node_get_foreground_color (theme_node, &color);
|
||||
clutter_text_set_color (CLUTTER_TEXT (priv->entry), &color);
|
||||
|
||||
if (st_theme_node_get_color (theme_node, "caret-color", FALSE, &color))
|
||||
clutter_text_set_cursor_color (CLUTTER_TEXT (priv->entry), &color);
|
||||
if (shell_theme_node_get_color (theme_node, "caret-color", FALSE, &color))
|
||||
clutter_text_set_cursor_color (CLUTTER_TEXT (priv->entry), &color);
|
||||
|
||||
if (st_theme_node_get_color (theme_node, "selection-background-color", FALSE, &color))
|
||||
if (shell_theme_node_get_color (theme_node, "selection-background-color", FALSE, &color))
|
||||
clutter_text_set_selection_color (CLUTTER_TEXT (priv->entry), &color);
|
||||
|
||||
font = st_theme_node_get_font (theme_node);
|
||||
font = shell_theme_node_get_font (theme_node);
|
||||
font_string = pango_font_description_to_string (font);
|
||||
clutter_text_set_font_name (CLUTTER_TEXT (priv->entry), font_string);
|
||||
g_free (font_string);
|
||||
|
||||
ST_WIDGET_CLASS (st_entry_parent_class)->style_changed (self);
|
||||
NBTK_WIDGET_CLASS (nbtk_entry_parent_class)->style_changed (self);
|
||||
}
|
||||
|
||||
static void
|
||||
st_entry_get_preferred_width (ClutterActor *actor,
|
||||
gfloat for_height,
|
||||
gfloat *min_width_p,
|
||||
gfloat *natural_width_p)
|
||||
nbtk_entry_get_preferred_width (ClutterActor *actor,
|
||||
gfloat for_height,
|
||||
gfloat *min_width_p,
|
||||
gfloat *natural_width_p)
|
||||
{
|
||||
StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
||||
NbtkEntryPrivate *priv = NBTK_ENTRY_PRIV (actor);
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (actor));
|
||||
gfloat icon_w;
|
||||
|
||||
st_theme_node_adjust_for_height (theme_node, &for_height);
|
||||
shell_theme_node_adjust_for_height (theme_node, &for_height);
|
||||
|
||||
clutter_actor_get_preferred_width (priv->entry, for_height,
|
||||
min_width_p,
|
||||
@ -243,20 +242,20 @@ st_entry_get_preferred_width (ClutterActor *actor,
|
||||
*natural_width_p += icon_w + priv->spacing;
|
||||
}
|
||||
|
||||
st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p);
|
||||
shell_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p);
|
||||
}
|
||||
|
||||
static void
|
||||
st_entry_get_preferred_height (ClutterActor *actor,
|
||||
gfloat for_width,
|
||||
gfloat *min_height_p,
|
||||
gfloat *natural_height_p)
|
||||
nbtk_entry_get_preferred_height (ClutterActor *actor,
|
||||
gfloat for_width,
|
||||
gfloat *min_height_p,
|
||||
gfloat *natural_height_p)
|
||||
{
|
||||
StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
||||
NbtkEntryPrivate *priv = NBTK_ENTRY_PRIV (actor);
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (actor));
|
||||
gfloat icon_h;
|
||||
|
||||
st_theme_node_adjust_for_width (theme_node, &for_width);
|
||||
shell_theme_node_adjust_for_width (theme_node, &for_width);
|
||||
|
||||
clutter_actor_get_preferred_height (priv->entry, for_width,
|
||||
min_height_p,
|
||||
@ -286,25 +285,25 @@ st_entry_get_preferred_height (ClutterActor *actor,
|
||||
*natural_height_p = icon_h;
|
||||
}
|
||||
|
||||
st_theme_node_adjust_preferred_height (theme_node, min_height_p, natural_height_p);
|
||||
shell_theme_node_adjust_preferred_height (theme_node, min_height_p, natural_height_p);
|
||||
}
|
||||
|
||||
static void
|
||||
st_entry_allocate (ClutterActor *actor,
|
||||
const ClutterActorBox *box,
|
||||
ClutterAllocationFlags flags)
|
||||
nbtk_entry_allocate (ClutterActor *actor,
|
||||
const ClutterActorBox *box,
|
||||
ClutterAllocationFlags flags)
|
||||
{
|
||||
StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
||||
NbtkEntryPrivate *priv = NBTK_ENTRY_PRIV (actor);
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (actor));
|
||||
ClutterActorClass *parent_class;
|
||||
ClutterActorBox content_box, child_box, icon_box;
|
||||
gfloat icon_w, icon_h;
|
||||
gfloat entry_h, min_h, pref_h, avail_h;
|
||||
|
||||
parent_class = CLUTTER_ACTOR_CLASS (st_entry_parent_class);
|
||||
parent_class = CLUTTER_ACTOR_CLASS (nbtk_entry_parent_class);
|
||||
parent_class->allocate (actor, box, flags);
|
||||
|
||||
st_theme_node_get_content_box (theme_node, box, &content_box);
|
||||
shell_theme_node_get_content_box (theme_node, box, &content_box);
|
||||
|
||||
avail_h = content_box.y2 - content_box.y1;
|
||||
|
||||
@ -365,10 +364,10 @@ st_entry_allocate (ClutterActor *actor,
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_text_focus_in_cb (ClutterText *text,
|
||||
clutter_text_focus_in_cb (ClutterText *text,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
|
||||
NbtkEntryPrivate *priv = NBTK_ENTRY_PRIV (actor);
|
||||
|
||||
/* remove the hint if visible */
|
||||
if (priv->hint
|
||||
@ -376,7 +375,7 @@ clutter_text_focus_in_cb (ClutterText *text,
|
||||
{
|
||||
clutter_text_set_text (text, "");
|
||||
}
|
||||
st_widget_set_style_pseudo_class (ST_WIDGET (actor), "focus");
|
||||
nbtk_widget_set_style_pseudo_class (NBTK_WIDGET (actor), "focus");
|
||||
clutter_text_set_cursor_visible (text, TRUE);
|
||||
}
|
||||
|
||||
@ -384,28 +383,28 @@ static void
|
||||
clutter_text_focus_out_cb (ClutterText *text,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
|
||||
NbtkEntryPrivate *priv = NBTK_ENTRY_PRIV (actor);
|
||||
|
||||
/* add a hint if the entry is empty */
|
||||
if (priv->hint && !strcmp (clutter_text_get_text (text), ""))
|
||||
{
|
||||
clutter_text_set_text (text, priv->hint);
|
||||
st_widget_set_style_pseudo_class (ST_WIDGET (actor), "indeterminate");
|
||||
nbtk_widget_set_style_pseudo_class (NBTK_WIDGET (actor), "indeterminate");
|
||||
}
|
||||
else
|
||||
{
|
||||
st_widget_set_style_pseudo_class (ST_WIDGET (actor), NULL);
|
||||
nbtk_widget_set_style_pseudo_class (NBTK_WIDGET (actor), NULL);
|
||||
}
|
||||
clutter_text_set_cursor_visible (text, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
st_entry_paint (ClutterActor *actor)
|
||||
nbtk_entry_paint (ClutterActor *actor)
|
||||
{
|
||||
StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
|
||||
NbtkEntryPrivate *priv = NBTK_ENTRY_PRIV (actor);
|
||||
ClutterActorClass *parent_class;
|
||||
|
||||
parent_class = CLUTTER_ACTOR_CLASS (st_entry_parent_class);
|
||||
parent_class = CLUTTER_ACTOR_CLASS (nbtk_entry_parent_class);
|
||||
parent_class->paint (actor);
|
||||
|
||||
clutter_actor_paint (priv->entry);
|
||||
@ -418,12 +417,12 @@ st_entry_paint (ClutterActor *actor)
|
||||
}
|
||||
|
||||
static void
|
||||
st_entry_pick (ClutterActor *actor,
|
||||
const ClutterColor *c)
|
||||
nbtk_entry_pick (ClutterActor *actor,
|
||||
const ClutterColor *c)
|
||||
{
|
||||
StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
|
||||
NbtkEntryPrivate *priv = NBTK_ENTRY_PRIV (actor);
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_entry_parent_class)->pick (actor, c);
|
||||
CLUTTER_ACTOR_CLASS (nbtk_entry_parent_class)->pick (actor, c);
|
||||
|
||||
clutter_actor_paint (priv->entry);
|
||||
|
||||
@ -435,11 +434,11 @@ st_entry_pick (ClutterActor *actor,
|
||||
}
|
||||
|
||||
static void
|
||||
st_entry_map (ClutterActor *actor)
|
||||
nbtk_entry_map (ClutterActor *actor)
|
||||
{
|
||||
StEntryPrivate *priv = ST_ENTRY (actor)->priv;
|
||||
NbtkEntryPrivate *priv = NBTK_ENTRY (actor)->priv;
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_entry_parent_class)->map (actor);
|
||||
CLUTTER_ACTOR_CLASS (nbtk_entry_parent_class)->map (actor);
|
||||
|
||||
clutter_actor_map (priv->entry);
|
||||
|
||||
@ -451,11 +450,11 @@ st_entry_map (ClutterActor *actor)
|
||||
}
|
||||
|
||||
static void
|
||||
st_entry_unmap (ClutterActor *actor)
|
||||
nbtk_entry_unmap (ClutterActor *actor)
|
||||
{
|
||||
StEntryPrivate *priv = ST_ENTRY (actor)->priv;
|
||||
NbtkEntryPrivate *priv = NBTK_ENTRY (actor)->priv;
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_entry_parent_class)->unmap (actor);
|
||||
CLUTTER_ACTOR_CLASS (nbtk_entry_parent_class)->unmap (actor);
|
||||
|
||||
clutter_actor_unmap (priv->entry);
|
||||
|
||||
@ -467,11 +466,11 @@ st_entry_unmap (ClutterActor *actor)
|
||||
}
|
||||
|
||||
static void
|
||||
st_entry_clipboard_callback (StClipboard *clipboard,
|
||||
const gchar *text,
|
||||
gpointer data)
|
||||
nbtk_entry_clipboard_callback (NbtkClipboard *clipboard,
|
||||
const gchar *text,
|
||||
gpointer data)
|
||||
{
|
||||
ClutterText *ctext = (ClutterText*)((StEntry *) data)->priv->entry;
|
||||
ClutterText *ctext = (ClutterText*) ((NbtkEntry *) data)->priv->entry;
|
||||
gint cursor_pos;
|
||||
|
||||
if (!text)
|
||||
@ -486,10 +485,10 @@ st_entry_clipboard_callback (StClipboard *clipboard,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
st_entry_key_press_event (ClutterActor *actor,
|
||||
ClutterKeyEvent *event)
|
||||
nbtk_entry_key_press_event (ClutterActor *actor,
|
||||
ClutterKeyEvent *event)
|
||||
{
|
||||
StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
|
||||
NbtkEntryPrivate *priv = NBTK_ENTRY_PRIV (actor);
|
||||
|
||||
/* This is expected to handle events that were emitted for the inner
|
||||
ClutterText. They only reach this function if the ClutterText
|
||||
@ -499,11 +498,11 @@ st_entry_key_press_event (ClutterActor *actor,
|
||||
if ((event->modifier_state & CLUTTER_CONTROL_MASK)
|
||||
&& event->keyval == CLUTTER_v)
|
||||
{
|
||||
StClipboard *clipboard;
|
||||
NbtkClipboard *clipboard;
|
||||
|
||||
clipboard = st_clipboard_get_default ();
|
||||
clipboard = nbtk_clipboard_get_default ();
|
||||
|
||||
st_clipboard_get_text (clipboard, st_entry_clipboard_callback, actor);
|
||||
nbtk_clipboard_get_text (clipboard, nbtk_entry_clipboard_callback, actor);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -512,15 +511,15 @@ st_entry_key_press_event (ClutterActor *actor,
|
||||
if ((event->modifier_state & CLUTTER_CONTROL_MASK)
|
||||
&& event->keyval == CLUTTER_c)
|
||||
{
|
||||
StClipboard *clipboard;
|
||||
NbtkClipboard *clipboard;
|
||||
gchar *text;
|
||||
|
||||
clipboard = st_clipboard_get_default ();
|
||||
clipboard = nbtk_clipboard_get_default ();
|
||||
|
||||
text = clutter_text_get_selection ((ClutterText*) priv->entry);
|
||||
|
||||
if (text && strlen (text))
|
||||
st_clipboard_set_text (clipboard, text);
|
||||
nbtk_clipboard_set_text (clipboard, text);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -530,16 +529,16 @@ st_entry_key_press_event (ClutterActor *actor,
|
||||
if ((event->modifier_state & CLUTTER_CONTROL_MASK)
|
||||
&& event->keyval == CLUTTER_x)
|
||||
{
|
||||
StClipboard *clipboard;
|
||||
NbtkClipboard *clipboard;
|
||||
gchar *text;
|
||||
|
||||
clipboard = st_clipboard_get_default ();
|
||||
clipboard = nbtk_clipboard_get_default ();
|
||||
|
||||
text = clutter_text_get_selection ((ClutterText*) priv->entry);
|
||||
|
||||
if (text && strlen (text))
|
||||
{
|
||||
st_clipboard_set_text (clipboard, text);
|
||||
nbtk_clipboard_set_text (clipboard, text);
|
||||
|
||||
/* now delete the text */
|
||||
clutter_text_delete_selection ((ClutterText *) priv->entry);
|
||||
@ -552,9 +551,9 @@ st_entry_key_press_event (ClutterActor *actor,
|
||||
}
|
||||
|
||||
static void
|
||||
st_entry_key_focus_in (ClutterActor *actor)
|
||||
nbtk_entry_key_focus_in (ClutterActor *actor)
|
||||
{
|
||||
StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
|
||||
NbtkEntryPrivate *priv = NBTK_ENTRY_PRIV (actor);
|
||||
|
||||
/* We never want key focus. The ClutterText should be given first
|
||||
pass for all key events */
|
||||
@ -562,32 +561,32 @@ st_entry_key_focus_in (ClutterActor *actor)
|
||||
}
|
||||
|
||||
static void
|
||||
st_entry_class_init (StEntryClass *klass)
|
||||
nbtk_entry_class_init (NbtkEntryClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
||||
StWidgetClass *widget_class = ST_WIDGET_CLASS (klass);
|
||||
NbtkWidgetClass *widget_class = NBTK_WIDGET_CLASS (klass);
|
||||
GParamSpec *pspec;
|
||||
|
||||
g_type_class_add_private (klass, sizeof (StEntryPrivate));
|
||||
g_type_class_add_private (klass, sizeof (NbtkEntryPrivate));
|
||||
|
||||
gobject_class->set_property = st_entry_set_property;
|
||||
gobject_class->get_property = st_entry_get_property;
|
||||
gobject_class->finalize = st_entry_finalize;
|
||||
gobject_class->dispose = st_entry_dispose;
|
||||
gobject_class->set_property = nbtk_entry_set_property;
|
||||
gobject_class->get_property = nbtk_entry_get_property;
|
||||
gobject_class->finalize = nbtk_entry_finalize;
|
||||
gobject_class->dispose = nbtk_entry_dispose;
|
||||
|
||||
actor_class->get_preferred_width = st_entry_get_preferred_width;
|
||||
actor_class->get_preferred_height = st_entry_get_preferred_height;
|
||||
actor_class->allocate = st_entry_allocate;
|
||||
actor_class->paint = st_entry_paint;
|
||||
actor_class->pick = st_entry_pick;
|
||||
actor_class->map = st_entry_map;
|
||||
actor_class->unmap = st_entry_unmap;
|
||||
actor_class->get_preferred_width = nbtk_entry_get_preferred_width;
|
||||
actor_class->get_preferred_height = nbtk_entry_get_preferred_height;
|
||||
actor_class->allocate = nbtk_entry_allocate;
|
||||
actor_class->paint = nbtk_entry_paint;
|
||||
actor_class->pick = nbtk_entry_pick;
|
||||
actor_class->map = nbtk_entry_map;
|
||||
actor_class->unmap = nbtk_entry_unmap;
|
||||
|
||||
actor_class->key_press_event = st_entry_key_press_event;
|
||||
actor_class->key_focus_in = st_entry_key_focus_in;
|
||||
actor_class->key_press_event = nbtk_entry_key_press_event;
|
||||
actor_class->key_focus_in = nbtk_entry_key_focus_in;
|
||||
|
||||
widget_class->style_changed = st_entry_style_changed;
|
||||
widget_class->style_changed = nbtk_entry_style_changed;
|
||||
|
||||
pspec = g_param_spec_object ("clutter-text",
|
||||
"Clutter Text",
|
||||
@ -611,7 +610,7 @@ st_entry_class_init (StEntryClass *klass)
|
||||
|
||||
/* signals */
|
||||
/**
|
||||
* StEntry::primary-icon-clicked:
|
||||
* NbtkEntry::primary-icon-clicked:
|
||||
*
|
||||
* Emitted when the primary icon is clicked
|
||||
*/
|
||||
@ -619,12 +618,12 @@ st_entry_class_init (StEntryClass *klass)
|
||||
g_signal_new ("primary-icon-clicked",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (StEntryClass, primary_icon_clicked),
|
||||
G_STRUCT_OFFSET (NbtkEntryClass, primary_icon_clicked),
|
||||
NULL, NULL,
|
||||
_st_marshal_VOID__VOID,
|
||||
_nbtk_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
/**
|
||||
* StEntry::secondary-icon-clicked:
|
||||
* NbtkEntry::secondary-icon-clicked:
|
||||
*
|
||||
* Emitted when the secondary icon is clicked
|
||||
*/
|
||||
@ -632,18 +631,18 @@ st_entry_class_init (StEntryClass *klass)
|
||||
g_signal_new ("secondary-icon-clicked",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (StEntryClass, secondary_icon_clicked),
|
||||
G_STRUCT_OFFSET (NbtkEntryClass, secondary_icon_clicked),
|
||||
NULL, NULL,
|
||||
_st_marshal_VOID__VOID,
|
||||
_nbtk_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
st_entry_init (StEntry *entry)
|
||||
nbtk_entry_init (NbtkEntry *entry)
|
||||
{
|
||||
StEntryPrivate *priv;
|
||||
NbtkEntryPrivate *priv;
|
||||
|
||||
priv = entry->priv = ST_ENTRY_GET_PRIVATE (entry);
|
||||
priv = entry->priv = NBTK_ENTRY_GET_PRIVATE (entry);
|
||||
|
||||
priv->entry = g_object_new (CLUTTER_TYPE_IMTEXT,
|
||||
"line-alignment", PANGO_ALIGN_LEFT,
|
||||
@ -668,20 +667,20 @@ st_entry_init (StEntry *entry)
|
||||
}
|
||||
|
||||
/**
|
||||
* st_entry_new:
|
||||
* nbtk_entry_new:
|
||||
* @text: text to set the entry to
|
||||
*
|
||||
* Create a new #StEntry with the specified entry
|
||||
* Create a new #NbtkEntry with the specified entry
|
||||
*
|
||||
* Returns: a new #StEntry
|
||||
* Returns: a new #NbtkEntry
|
||||
*/
|
||||
StWidget *
|
||||
st_entry_new (const gchar *text)
|
||||
NbtkWidget *
|
||||
nbtk_entry_new (const gchar *text)
|
||||
{
|
||||
StWidget *entry;
|
||||
NbtkWidget *entry;
|
||||
|
||||
/* add the entry to the stage, but don't allow it to be visible */
|
||||
entry = g_object_new (ST_TYPE_ENTRY,
|
||||
entry = g_object_new (NBTK_TYPE_ENTRY,
|
||||
"text", text,
|
||||
NULL);
|
||||
|
||||
@ -689,35 +688,35 @@ st_entry_new (const gchar *text)
|
||||
}
|
||||
|
||||
/**
|
||||
* st_entry_get_text:
|
||||
* @entry: a #StEntry
|
||||
* nbtk_entry_get_text:
|
||||
* @entry: a #NbtkEntry
|
||||
*
|
||||
* Get the text displayed on the entry
|
||||
*
|
||||
* Returns: the text for the entry. This must not be freed by the application
|
||||
*/
|
||||
G_CONST_RETURN gchar *
|
||||
st_entry_get_text (StEntry *entry)
|
||||
nbtk_entry_get_text (NbtkEntry *entry)
|
||||
{
|
||||
g_return_val_if_fail (ST_IS_ENTRY (entry), NULL);
|
||||
g_return_val_if_fail (NBTK_IS_ENTRY (entry), NULL);
|
||||
|
||||
return clutter_text_get_text (CLUTTER_TEXT (entry->priv->entry));
|
||||
}
|
||||
|
||||
/**
|
||||
* st_entry_set_text:
|
||||
* @entry: a #StEntry
|
||||
* nbtk_entry_set_text:
|
||||
* @entry: a #NbtkEntry
|
||||
* @text: text to set the entry to
|
||||
*
|
||||
* Sets the text displayed on the entry
|
||||
*/
|
||||
void
|
||||
st_entry_set_text (StEntry *entry,
|
||||
const gchar *text)
|
||||
nbtk_entry_set_text (NbtkEntry *entry,
|
||||
const gchar *text)
|
||||
{
|
||||
StEntryPrivate *priv;
|
||||
NbtkEntryPrivate *priv;
|
||||
|
||||
g_return_if_fail (ST_IS_ENTRY (entry));
|
||||
g_return_if_fail (NBTK_IS_ENTRY (entry));
|
||||
|
||||
priv = entry->priv;
|
||||
|
||||
@ -727,14 +726,14 @@ st_entry_set_text (StEntry *entry,
|
||||
&& !HAS_FOCUS (priv->entry))
|
||||
{
|
||||
text = priv->hint;
|
||||
st_widget_set_style_pseudo_class (ST_WIDGET (entry), "indeterminate");
|
||||
nbtk_widget_set_style_pseudo_class (NBTK_WIDGET (entry), "indeterminate");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (HAS_FOCUS (priv->entry))
|
||||
st_widget_set_style_pseudo_class (ST_WIDGET (entry), "focus");
|
||||
nbtk_widget_set_style_pseudo_class (NBTK_WIDGET (entry), "focus");
|
||||
else
|
||||
st_widget_set_style_pseudo_class (ST_WIDGET (entry), NULL);
|
||||
nbtk_widget_set_style_pseudo_class (NBTK_WIDGET (entry), NULL);
|
||||
}
|
||||
|
||||
clutter_text_set_text (CLUTTER_TEXT (priv->entry), text);
|
||||
@ -743,25 +742,25 @@ st_entry_set_text (StEntry *entry,
|
||||
}
|
||||
|
||||
/**
|
||||
* st_entry_get_clutter_text:
|
||||
* @entry: a #StEntry
|
||||
* nbtk_entry_get_clutter_text:
|
||||
* @entry: a #NbtkEntry
|
||||
*
|
||||
* Retrieve the internal #ClutterText so that extra parameters can be set
|
||||
*
|
||||
* Returns: (transfer none): the #ClutterText used by #StEntry. The entry is
|
||||
* owned by the #StEntry and should not be unref'ed by the application.
|
||||
* Returns: (transfer none): the #ClutterText used by #NbtkEntry. The entry is
|
||||
* owned by the #NbtkEntry and should not be unref'ed by the application.
|
||||
*/
|
||||
ClutterActor*
|
||||
st_entry_get_clutter_text (StEntry *entry)
|
||||
nbtk_entry_get_clutter_text (NbtkEntry *entry)
|
||||
{
|
||||
g_return_val_if_fail (ST_ENTRY (entry), NULL);
|
||||
g_return_val_if_fail (NBTK_ENTRY (entry), NULL);
|
||||
|
||||
return entry->priv->entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* st_entry_set_hint_text:
|
||||
* @entry: a #StEntry
|
||||
* nbtk_entry_set_hint_text:
|
||||
* @entry: a #NbtkEntry
|
||||
* @text: text to set as the entry hint
|
||||
*
|
||||
* Sets the text to display when the entry is empty and unfocused. When the
|
||||
@ -769,12 +768,12 @@ st_entry_get_clutter_text (StEntry *entry)
|
||||
* A value of NULL unsets the hint.
|
||||
*/
|
||||
void
|
||||
st_entry_set_hint_text (StEntry *entry,
|
||||
const gchar *text)
|
||||
nbtk_entry_set_hint_text (NbtkEntry *entry,
|
||||
const gchar *text)
|
||||
{
|
||||
StEntryPrivate *priv;
|
||||
NbtkEntryPrivate *priv;
|
||||
|
||||
g_return_if_fail (ST_IS_ENTRY (entry));
|
||||
g_return_if_fail (NBTK_IS_ENTRY (entry));
|
||||
|
||||
priv = entry->priv;
|
||||
|
||||
@ -785,34 +784,34 @@ st_entry_set_hint_text (StEntry *entry,
|
||||
if (!strcmp (clutter_text_get_text (CLUTTER_TEXT (priv->entry)), ""))
|
||||
{
|
||||
clutter_text_set_text (CLUTTER_TEXT (priv->entry), priv->hint);
|
||||
st_widget_set_style_pseudo_class (ST_WIDGET (entry), "indeterminate");
|
||||
nbtk_widget_set_style_pseudo_class (NBTK_WIDGET (entry), "indeterminate");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* st_entry_get_hint_text:
|
||||
* @entry: a #StEntry
|
||||
* nbtk_entry_get_hint_text:
|
||||
* @entry: a #NbtkEntry
|
||||
*
|
||||
* Gets the text that is displayed when the entry is empty and unfocused
|
||||
*
|
||||
* Returns: the current value of the hint property. This string is owned by the
|
||||
* #StEntry and should not be freed or modified.
|
||||
* #NbtkEntry and should not be freed or modified.
|
||||
*/
|
||||
G_CONST_RETURN
|
||||
gchar *
|
||||
st_entry_get_hint_text (StEntry *entry)
|
||||
nbtk_entry_get_hint_text (NbtkEntry *entry)
|
||||
{
|
||||
g_return_val_if_fail (ST_IS_ENTRY (entry), NULL);
|
||||
g_return_val_if_fail (NBTK_IS_ENTRY (entry), NULL);
|
||||
|
||||
return entry->priv->hint;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_st_entry_icon_press_cb (ClutterActor *actor,
|
||||
ClutterButtonEvent *event,
|
||||
StEntry *entry)
|
||||
_nbtk_entry_icon_press_cb (ClutterActor *actor,
|
||||
ClutterButtonEvent *event,
|
||||
NbtkEntry *entry)
|
||||
{
|
||||
StEntryPrivate *priv = entry->priv;
|
||||
NbtkEntryPrivate *priv = entry->priv;
|
||||
|
||||
if (actor == priv->primary_icon)
|
||||
g_signal_emit (entry, entry_signals[PRIMARY_ICON_CLICKED], 0);
|
||||
@ -823,14 +822,14 @@ _st_entry_icon_press_cb (ClutterActor *actor,
|
||||
}
|
||||
|
||||
static void
|
||||
_st_entry_set_icon_from_file (StEntry *entry,
|
||||
ClutterActor **icon,
|
||||
const gchar *filename)
|
||||
_nbtk_entry_set_icon_from_file (NbtkEntry *entry,
|
||||
ClutterActor **icon,
|
||||
const gchar *filename)
|
||||
{
|
||||
if (*icon)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (*icon,
|
||||
_st_entry_icon_press_cb,
|
||||
_nbtk_entry_icon_press_cb,
|
||||
entry);
|
||||
clutter_actor_unparent (*icon);
|
||||
*icon = NULL;
|
||||
@ -838,62 +837,61 @@ _st_entry_set_icon_from_file (StEntry *entry,
|
||||
|
||||
if (filename)
|
||||
{
|
||||
StTextureCache *cache;
|
||||
NbtkTextureCache *cache;
|
||||
|
||||
cache = st_texture_cache_get_default ();
|
||||
cache = nbtk_texture_cache_get_default ();
|
||||
|
||||
|
||||
|
||||
*icon = (ClutterActor*) st_texture_cache_get_texture (cache, filename);
|
||||
*icon = (ClutterActor*) nbtk_texture_cache_get_texture (cache, filename, FALSE);
|
||||
|
||||
clutter_actor_set_reactive (*icon, TRUE);
|
||||
clutter_actor_set_parent (*icon, CLUTTER_ACTOR (entry));
|
||||
g_signal_connect (*icon, "button-release-event",
|
||||
G_CALLBACK (_st_entry_icon_press_cb), entry);
|
||||
G_CALLBACK (_nbtk_entry_icon_press_cb), entry);
|
||||
}
|
||||
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (entry));
|
||||
}
|
||||
|
||||
/**
|
||||
* st_entry_set_primary_icon_from_file:
|
||||
* @entry: a #StEntry
|
||||
* nbtk_entry_set_primary_icon_from_file:
|
||||
* @entry: a #NbtkEntry
|
||||
* @filename: filename of an icon
|
||||
*
|
||||
* Set the primary icon of the entry to the given filename
|
||||
*/
|
||||
void
|
||||
st_entry_set_primary_icon_from_file (StEntry *entry,
|
||||
const gchar *filename)
|
||||
nbtk_entry_set_primary_icon_from_file (NbtkEntry *entry,
|
||||
const gchar *filename)
|
||||
{
|
||||
StEntryPrivate *priv;
|
||||
NbtkEntryPrivate *priv;
|
||||
|
||||
g_return_if_fail (ST_IS_ENTRY (entry));
|
||||
g_return_if_fail (NBTK_IS_ENTRY (entry));
|
||||
|
||||
priv = entry->priv;
|
||||
|
||||
_st_entry_set_icon_from_file (entry, &priv->primary_icon, filename);
|
||||
_nbtk_entry_set_icon_from_file (entry, &priv->primary_icon, filename);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* st_entry_set_secondary_icon_from_file:
|
||||
* @entry: a #StEntry
|
||||
* nbtk_entry_set_secondary_icon_from_file:
|
||||
* @entry: a #NbtkEntry
|
||||
* @filename: filename of an icon
|
||||
*
|
||||
* Set the primary icon of the entry to the given filename
|
||||
*/
|
||||
void
|
||||
st_entry_set_secondary_icon_from_file (StEntry *entry,
|
||||
const gchar *filename)
|
||||
nbtk_entry_set_secondary_icon_from_file (NbtkEntry *entry,
|
||||
const gchar *filename)
|
||||
{
|
||||
StEntryPrivate *priv;
|
||||
NbtkEntryPrivate *priv;
|
||||
|
||||
g_return_if_fail (ST_IS_ENTRY (entry));
|
||||
g_return_if_fail (NBTK_IS_ENTRY (entry));
|
||||
|
||||
priv = entry->priv;
|
||||
|
||||
_st_entry_set_icon_from_file (entry, &priv->secondary_icon, filename);
|
||||
_nbtk_entry_set_icon_from_file (entry, &priv->secondary_icon, filename);
|
||||
|
||||
}
|
||||
|
88
src/nbtk/nbtk-entry.h
Normal file
88
src/nbtk/nbtk-entry.h
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* nbtk-entry.h: Plain entry actor
|
||||
*
|
||||
* Copyright 2008, 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Written by: Thomas Wood <thomas@linux.intel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(NBTK_H_INSIDE) && !defined(NBTK_COMPILATION)
|
||||
#error "Only <nbtk/nbtk.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef __NBTK_ENTRY_H__
|
||||
#define __NBTK_ENTRY_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#include <nbtk/nbtk-widget.h>
|
||||
|
||||
#define NBTK_TYPE_ENTRY (nbtk_entry_get_type ())
|
||||
#define NBTK_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NBTK_TYPE_ENTRY, NbtkEntry))
|
||||
#define NBTK_IS_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NBTK_TYPE_ENTRY))
|
||||
#define NBTK_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NBTK_TYPE_ENTRY, NbtkEntryClass))
|
||||
#define NBTK_IS_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NBTK_TYPE_ENTRY))
|
||||
#define NBTK_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NBTK_TYPE_ENTRY, NbtkEntryClass))
|
||||
|
||||
typedef struct _NbtkEntry NbtkEntry;
|
||||
typedef struct _NbtkEntryPrivate NbtkEntryPrivate;
|
||||
typedef struct _NbtkEntryClass NbtkEntryClass;
|
||||
|
||||
/**
|
||||
* NbtkEntry:
|
||||
*
|
||||
* The contents of this structure is private and should only be accessed using
|
||||
* the provided API.
|
||||
*/
|
||||
struct _NbtkEntry
|
||||
{
|
||||
/*< private >*/
|
||||
NbtkWidget parent_instance;
|
||||
|
||||
NbtkEntryPrivate *priv;
|
||||
};
|
||||
|
||||
struct _NbtkEntryClass
|
||||
{
|
||||
NbtkWidgetClass parent_class;
|
||||
|
||||
/* signals */
|
||||
void (*primary_icon_clicked) (NbtkEntry *entry);
|
||||
void (*secondary_icon_clicked) (NbtkEntry *entry);
|
||||
};
|
||||
|
||||
GType nbtk_entry_get_type (void) G_GNUC_CONST;
|
||||
|
||||
NbtkWidget * nbtk_entry_new (const gchar *text);
|
||||
G_CONST_RETURN gchar *nbtk_entry_get_text (NbtkEntry *entry);
|
||||
void nbtk_entry_set_text (NbtkEntry *entry,
|
||||
const gchar *text);
|
||||
ClutterActor* nbtk_entry_get_clutter_text (NbtkEntry *entry);
|
||||
|
||||
void nbtk_entry_set_hint_text (NbtkEntry *entry,
|
||||
const gchar *text);
|
||||
G_CONST_RETURN gchar *nbtk_entry_get_hint_text (NbtkEntry *entry);
|
||||
|
||||
void nbtk_entry_set_primary_icon_from_file (NbtkEntry *entry,
|
||||
const gchar *filename);
|
||||
void nbtk_entry_set_secondary_icon_from_file (NbtkEntry *entry,
|
||||
const gchar *filename);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NBTK_ENTRY_H__ */
|
@ -1,5 +1,5 @@
|
||||
/*** BEGIN file-header ***/
|
||||
#include "st-enum-types.h"
|
||||
#include "nbtk-enum-types.h"
|
||||
/*** END file-header ***/
|
||||
|
||||
/*** BEGIN file-production ***/
|
@ -1,10 +1,10 @@
|
||||
/*** BEGIN file-header ***/
|
||||
#if !defined(ST_H_INSIDE) && !defined(ST_COMPILATION)
|
||||
#error "Only <st/st.h> can be included directly.h"
|
||||
#if !defined(NBTK_H_INSIDE) && !defined(NBTK_COMPILATION)
|
||||
#error "Only <nbtk/nbtk.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef __ST_ENUM_TYPES_H__
|
||||
#define __ST_ENUM_TYPES_H__
|
||||
#ifndef __NBTK_ENUM_TYPES_H__
|
||||
#define __NBTK_ENUM_TYPES_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
@ -19,11 +19,11 @@ G_BEGIN_DECLS
|
||||
/*** BEGIN file-tail ***/
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* !__ST_ENUM_TYPES_H__ */
|
||||
#endif /* !__NBTK_ENUM_TYPES_H__ */
|
||||
/*** END file-tail ***/
|
||||
|
||||
/*** BEGIN value-header ***/
|
||||
GType @enum_name@_get_type (void) G_GNUC_CONST;
|
||||
#define ST_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
|
||||
#define NBTK_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
|
||||
|
||||
/*** END value-header ***/
|
341
src/nbtk/nbtk-label.c
Normal file
341
src/nbtk/nbtk-label.c
Normal file
@ -0,0 +1,341 @@
|
||||
/*
|
||||
* nbtk-label.c: Plain label actor
|
||||
*
|
||||
* Copyright 2008,2009 Intel Corporation
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Written by: Thomas Wood <thomas@linux.intel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:nbtk-label
|
||||
* @short_description: Widget for displaying text
|
||||
*
|
||||
* #NbtkLabel is a simple widget for displaying text. It derives from
|
||||
* #NbtkWidget to add extra style and placement functionality over
|
||||
* #ClutterText. The internal #ClutterText is publicly accessibly to allow
|
||||
* applications to set further properties.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
#include "nbtk-label.h"
|
||||
|
||||
#include "nbtk-widget.h"
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
||||
PROP_CLUTTER_TEXT,
|
||||
PROP_TEXT
|
||||
};
|
||||
|
||||
#define NBTK_LABEL_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), NBTK_TYPE_LABEL, NbtkLabelPrivate))
|
||||
|
||||
struct _NbtkLabelPrivate
|
||||
{
|
||||
ClutterActor *label;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (NbtkLabel, nbtk_label, NBTK_TYPE_WIDGET);
|
||||
|
||||
static void
|
||||
nbtk_label_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
NbtkLabel *label = NBTK_LABEL (gobject);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_TEXT:
|
||||
nbtk_label_set_text (label, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_label_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
NbtkLabelPrivate *priv = NBTK_LABEL (gobject)->priv;
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_CLUTTER_TEXT:
|
||||
g_value_set_object (value, priv->label);
|
||||
break;
|
||||
|
||||
case PROP_TEXT:
|
||||
g_value_set_string (value, clutter_text_get_text (CLUTTER_TEXT (priv->label)));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_label_style_changed (NbtkWidget *self)
|
||||
{
|
||||
NbtkLabelPrivate *priv;
|
||||
ShellThemeNode *theme_node;
|
||||
ClutterColor color;
|
||||
const PangoFontDescription *font;
|
||||
gchar *font_string;
|
||||
|
||||
priv = NBTK_LABEL (self)->priv;
|
||||
theme_node = nbtk_widget_get_theme_node (self);
|
||||
shell_theme_node_get_foreground_color (theme_node, &color);
|
||||
clutter_text_set_color (CLUTTER_TEXT (priv->label), &color);
|
||||
|
||||
font = shell_theme_node_get_font (theme_node);
|
||||
font_string = pango_font_description_to_string (font);
|
||||
clutter_text_set_font_name (CLUTTER_TEXT (priv->label), font_string);
|
||||
g_free (font_string);
|
||||
|
||||
NBTK_WIDGET_CLASS (nbtk_label_parent_class)->style_changed (self);
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_label_get_preferred_width (ClutterActor *actor,
|
||||
gfloat for_height,
|
||||
gfloat *min_width_p,
|
||||
gfloat *natural_width_p)
|
||||
{
|
||||
NbtkLabelPrivate *priv = NBTK_LABEL (actor)->priv;
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (actor));
|
||||
|
||||
shell_theme_node_adjust_for_height (theme_node, &for_height);
|
||||
|
||||
clutter_actor_get_preferred_width (priv->label, for_height,
|
||||
min_width_p,
|
||||
natural_width_p);
|
||||
|
||||
shell_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p);
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_label_get_preferred_height (ClutterActor *actor,
|
||||
gfloat for_width,
|
||||
gfloat *min_height_p,
|
||||
gfloat *natural_height_p)
|
||||
{
|
||||
NbtkLabelPrivate *priv = NBTK_LABEL (actor)->priv;
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (actor));
|
||||
|
||||
shell_theme_node_adjust_for_width (theme_node, &for_width);
|
||||
|
||||
clutter_actor_get_preferred_height (priv->label, for_width,
|
||||
min_height_p,
|
||||
natural_height_p);
|
||||
|
||||
shell_theme_node_adjust_preferred_height (theme_node, min_height_p, natural_height_p);
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_label_allocate (ClutterActor *actor,
|
||||
const ClutterActorBox *box,
|
||||
ClutterAllocationFlags flags)
|
||||
{
|
||||
NbtkLabelPrivate *priv = NBTK_LABEL (actor)->priv;
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (actor));
|
||||
ClutterActorClass *parent_class;
|
||||
ClutterActorBox content_box;
|
||||
|
||||
shell_theme_node_get_content_box (theme_node, box, &content_box);
|
||||
|
||||
parent_class = CLUTTER_ACTOR_CLASS (nbtk_label_parent_class);
|
||||
parent_class->allocate (actor, box, flags);
|
||||
|
||||
clutter_actor_allocate (priv->label, &content_box, flags);
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_label_paint (ClutterActor *actor)
|
||||
{
|
||||
NbtkLabelPrivate *priv = NBTK_LABEL (actor)->priv;
|
||||
ClutterActorClass *parent_class;
|
||||
|
||||
parent_class = CLUTTER_ACTOR_CLASS (nbtk_label_parent_class);
|
||||
parent_class->paint (actor);
|
||||
|
||||
clutter_actor_paint (priv->label);
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_label_map (ClutterActor *actor)
|
||||
{
|
||||
NbtkLabelPrivate *priv = NBTK_LABEL (actor)->priv;
|
||||
|
||||
CLUTTER_ACTOR_CLASS (nbtk_label_parent_class)->map (actor);
|
||||
|
||||
clutter_actor_map (priv->label);
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_label_unmap (ClutterActor *actor)
|
||||
{
|
||||
NbtkLabelPrivate *priv = NBTK_LABEL (actor)->priv;
|
||||
|
||||
CLUTTER_ACTOR_CLASS (nbtk_label_parent_class)->unmap (actor);
|
||||
|
||||
clutter_actor_unmap (priv->label);
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_label_class_init (NbtkLabelClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
||||
NbtkWidgetClass *widget_class = NBTK_WIDGET_CLASS (klass);
|
||||
GParamSpec *pspec;
|
||||
|
||||
g_type_class_add_private (klass, sizeof (NbtkLabelPrivate));
|
||||
|
||||
gobject_class->set_property = nbtk_label_set_property;
|
||||
gobject_class->get_property = nbtk_label_get_property;
|
||||
|
||||
actor_class->paint = nbtk_label_paint;
|
||||
actor_class->allocate = nbtk_label_allocate;
|
||||
actor_class->get_preferred_width = nbtk_label_get_preferred_width;
|
||||
actor_class->get_preferred_height = nbtk_label_get_preferred_height;
|
||||
actor_class->map = nbtk_label_map;
|
||||
actor_class->unmap = nbtk_label_unmap;
|
||||
|
||||
widget_class->style_changed = nbtk_label_style_changed;
|
||||
|
||||
pspec = g_param_spec_object ("clutter-text",
|
||||
"Clutter Text",
|
||||
"Internal ClutterText actor",
|
||||
CLUTTER_TYPE_TEXT,
|
||||
G_PARAM_READABLE);
|
||||
g_object_class_install_property (gobject_class, PROP_CLUTTER_TEXT, pspec);
|
||||
|
||||
pspec = g_param_spec_string ("text",
|
||||
"Text",
|
||||
"Text of the label",
|
||||
NULL, G_PARAM_READWRITE);
|
||||
g_object_class_install_property (gobject_class, PROP_TEXT, pspec);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_label_init (NbtkLabel *label)
|
||||
{
|
||||
NbtkLabelPrivate *priv;
|
||||
|
||||
label->priv = priv = NBTK_LABEL_GET_PRIVATE (label);
|
||||
|
||||
label->priv->label = g_object_new (CLUTTER_TYPE_TEXT,
|
||||
"ellipsize", PANGO_ELLIPSIZE_END,
|
||||
NULL);
|
||||
|
||||
clutter_actor_set_parent (priv->label, CLUTTER_ACTOR (label));
|
||||
}
|
||||
|
||||
/**
|
||||
* nbtk_label_new:
|
||||
* @text: text to set the label to
|
||||
*
|
||||
* Create a new #NbtkLabel with the specified label
|
||||
*
|
||||
* Returns: a new #NbtkLabel
|
||||
*/
|
||||
NbtkWidget *
|
||||
nbtk_label_new (const gchar *text)
|
||||
{
|
||||
if (text == NULL || *text == '\0')
|
||||
return g_object_new (NBTK_TYPE_LABEL, NULL);
|
||||
else
|
||||
return g_object_new (NBTK_TYPE_LABEL,
|
||||
"text", text,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* nbtk_label_get_text:
|
||||
* @label: a #NbtkLabel
|
||||
*
|
||||
* Get the text displayed on the label
|
||||
*
|
||||
* Returns: the text for the label. This must not be freed by the application
|
||||
*/
|
||||
G_CONST_RETURN gchar *
|
||||
nbtk_label_get_text (NbtkLabel *label)
|
||||
{
|
||||
g_return_val_if_fail (NBTK_IS_LABEL (label), NULL);
|
||||
|
||||
return clutter_text_get_text (CLUTTER_TEXT (label->priv->label));
|
||||
}
|
||||
|
||||
/**
|
||||
* nbtk_label_set_text:
|
||||
* @label: a #NbtkLabel
|
||||
* @text: text to set the label to
|
||||
*
|
||||
* Sets the text displayed on the label
|
||||
*/
|
||||
void
|
||||
nbtk_label_set_text (NbtkLabel *label,
|
||||
const gchar *text)
|
||||
{
|
||||
NbtkLabelPrivate *priv;
|
||||
|
||||
g_return_if_fail (NBTK_IS_LABEL (label));
|
||||
g_return_if_fail (text != NULL);
|
||||
|
||||
priv = label->priv;
|
||||
|
||||
clutter_text_set_text (CLUTTER_TEXT (priv->label), text);
|
||||
|
||||
g_object_notify (G_OBJECT (label), "text");
|
||||
}
|
||||
|
||||
/**
|
||||
* nbtk_label_get_clutter_text:
|
||||
* @label: a #NbtkLabel
|
||||
*
|
||||
* Retrieve the internal #ClutterText so that extra parameters can be set
|
||||
*
|
||||
* Returns: (transfer none): ethe #ClutterText used by #NbtkLabel. The label
|
||||
* is owned by the #NbtkLabel and should not be unref'ed by the application.
|
||||
*/
|
||||
ClutterActor*
|
||||
nbtk_label_get_clutter_text (NbtkLabel *label)
|
||||
{
|
||||
g_return_val_if_fail (NBTK_LABEL (label), NULL);
|
||||
|
||||
return label->priv->label;
|
||||
}
|
75
src/nbtk/nbtk-label.h
Normal file
75
src/nbtk/nbtk-label.h
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* nbtk-label.h: Plain label actor
|
||||
*
|
||||
* Copyright 2008, 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Written by: Thomas Wood <thomas@linux.intel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(NBTK_H_INSIDE) && !defined(NBTK_COMPILATION)
|
||||
#error "Only <nbtk/nbtk.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef __NBTK_LABEL_H__
|
||||
#define __NBTK_LABEL_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#include <nbtk/nbtk-widget.h>
|
||||
|
||||
#define NBTK_TYPE_LABEL (nbtk_label_get_type ())
|
||||
#define NBTK_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NBTK_TYPE_LABEL, NbtkLabel))
|
||||
#define NBTK_IS_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NBTK_TYPE_LABEL))
|
||||
#define NBTK_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NBTK_TYPE_LABEL, NbtkLabelClass))
|
||||
#define NBTK_IS_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NBTK_TYPE_LABEL))
|
||||
#define NBTK_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NBTK_TYPE_LABEL, NbtkLabelClass))
|
||||
|
||||
typedef struct _NbtkLabel NbtkLabel;
|
||||
typedef struct _NbtkLabelPrivate NbtkLabelPrivate;
|
||||
typedef struct _NbtkLabelClass NbtkLabelClass;
|
||||
|
||||
/**
|
||||
* NbtkLabel:
|
||||
*
|
||||
* The contents of this structure is private and should only be accessed using
|
||||
* the provided API.
|
||||
*/
|
||||
struct _NbtkLabel
|
||||
{
|
||||
/*< private >*/
|
||||
NbtkWidget parent_instance;
|
||||
|
||||
NbtkLabelPrivate *priv;
|
||||
};
|
||||
|
||||
struct _NbtkLabelClass
|
||||
{
|
||||
NbtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
GType nbtk_label_get_type (void) G_GNUC_CONST;
|
||||
|
||||
NbtkWidget * nbtk_label_new (const gchar *text);
|
||||
G_CONST_RETURN gchar *nbtk_label_get_text (NbtkLabel *label);
|
||||
void nbtk_label_set_text (NbtkLabel *label,
|
||||
const gchar *text);
|
||||
ClutterActor * nbtk_label_get_clutter_text (NbtkLabel *label);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NBTK_LABEL_H__ */
|
@ -1,17 +1,16 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
#include "st-private.h"
|
||||
#include "nbtk-private.h"
|
||||
|
||||
/* Utility function to modify a child allocation box with respect to the
|
||||
* x/y-fill child properties. Expects childbox to contain the available
|
||||
* allocation space.
|
||||
*/
|
||||
void
|
||||
_st_allocate_fill (ClutterActor *child,
|
||||
ClutterActorBox *childbox,
|
||||
StAlign x_alignment,
|
||||
StAlign y_alignment,
|
||||
gboolean x_fill,
|
||||
gboolean y_fill)
|
||||
_nbtk_allocate_fill (ClutterActor *child,
|
||||
ClutterActorBox *childbox,
|
||||
NbtkAlign x_alignment,
|
||||
NbtkAlign y_alignment,
|
||||
gboolean x_fill,
|
||||
gboolean y_fill)
|
||||
{
|
||||
gfloat natural_width, natural_height;
|
||||
gfloat min_width, min_height;
|
||||
@ -21,16 +20,16 @@ _st_allocate_fill (ClutterActor *child,
|
||||
ClutterActorBox allocation = { 0, };
|
||||
gdouble x_align, y_align;
|
||||
|
||||
if (x_alignment == ST_ALIGN_START)
|
||||
if (x_alignment == NBTK_ALIGN_START)
|
||||
x_align = 0.0;
|
||||
else if (x_alignment == ST_ALIGN_MIDDLE)
|
||||
else if (x_alignment == NBTK_ALIGN_MIDDLE)
|
||||
x_align = 0.5;
|
||||
else
|
||||
x_align = 1.0;
|
||||
|
||||
if (y_alignment == ST_ALIGN_START)
|
||||
if (y_alignment == NBTK_ALIGN_START)
|
||||
y_align = 0.0;
|
||||
else if (y_alignment == ST_ALIGN_MIDDLE)
|
||||
else if (y_alignment == NBTK_ALIGN_MIDDLE)
|
||||
y_align = 0.5;
|
||||
else
|
||||
y_align = 1.0;
|
||||
@ -47,13 +46,13 @@ _st_allocate_fill (ClutterActor *child,
|
||||
if (x_fill)
|
||||
{
|
||||
allocation.x1 = childbox->x1;
|
||||
allocation.x2 = (int)(allocation.x1 + available_width);
|
||||
allocation.x2 = (int) (allocation.x1 + available_width);
|
||||
}
|
||||
|
||||
if (y_fill)
|
||||
{
|
||||
allocation.y1 = childbox->y1;
|
||||
allocation.y2 = (int)(allocation.y1 + available_height);
|
||||
allocation.y2 = (int) (allocation.y1 + available_height);
|
||||
}
|
||||
|
||||
/* if we are filling horizontally and vertically then we're done */
|
||||
@ -97,13 +96,13 @@ _st_allocate_fill (ClutterActor *child,
|
||||
|
||||
if (!x_fill)
|
||||
{
|
||||
allocation.x1 = childbox->x1 + (int)((available_width - child_width) * x_align);
|
||||
allocation.x1 = childbox->x1 + (int) ((available_width - child_width) * x_align);
|
||||
allocation.x2 = allocation.x1 + (int) child_width;
|
||||
}
|
||||
|
||||
if (!y_fill)
|
||||
{
|
||||
allocation.y1 = childbox->y1 + (int)((available_height - child_height) * y_align);
|
||||
allocation.y1 = childbox->y1 + (int) ((available_height - child_height) * y_align);
|
||||
allocation.y2 = allocation.y1 + (int) child_height;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-private.h: Private declarations
|
||||
* nbtk-private.h: Private declarations
|
||||
*
|
||||
* Copyright 2007 OpenedHand
|
||||
* Copyright 2009 Intel Corporation.
|
||||
@ -21,38 +20,30 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __ST_PRIVATE_H__
|
||||
#define __ST_PRIVATE_H__
|
||||
#ifndef __NBTK_PRIVATE_H__
|
||||
#define __NBTK_PRIVATE_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include "st-widget.h"
|
||||
#include "st-bin.h"
|
||||
#include "nbtk-widget.h"
|
||||
#include "nbtk-bin.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define I_(str) (g_intern_static_string ((str)))
|
||||
|
||||
#define ST_PARAM_READABLE \
|
||||
#define NBTK_PARAM_READABLE \
|
||||
(G_PARAM_READABLE | \
|
||||
G_PARAM_STATIC_NICK | G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB)
|
||||
|
||||
#define ST_PARAM_READWRITE \
|
||||
#define NBTK_PARAM_READWRITE \
|
||||
(G_PARAM_READABLE | G_PARAM_WRITABLE | \
|
||||
G_PARAM_STATIC_NICK | G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB)
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
ClutterActor *_st_widget_get_dnd_clone (StWidget *widget);
|
||||
ClutterActor *_nbtk_widget_get_dnd_clone (NbtkWidget *widget);
|
||||
void _nbtk_bin_get_align_factors (NbtkBin *bin, gdouble *x_align, gdouble *y_align);
|
||||
|
||||
void _st_bin_get_align_factors (StBin *bin,
|
||||
gdouble *x_align,
|
||||
gdouble *y_align);
|
||||
void _nbtk_allocate_fill (ClutterActor *child, ClutterActorBox *childbox, NbtkAlign x_align, NbtkAlign y_align, gboolean x_fill, gboolean y_fill);
|
||||
|
||||
void _st_allocate_fill (ClutterActor *child,
|
||||
ClutterActorBox *childbox,
|
||||
StAlign x_align,
|
||||
StAlign y_align,
|
||||
gboolean x_fill,
|
||||
gboolean y_fill);
|
||||
|
||||
#endif /* __ST_PRIVATE_H__ */
|
||||
#endif /* __NBTK_PRIVATE_H__ */
|
@ -1,6 +1,5 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-scroll-bar.c: Scroll bar actor
|
||||
* nbtk-scroll-bar.c: Scroll bar actor
|
||||
*
|
||||
* Copyright 2008 OpenedHand
|
||||
* Copyright 2009 Intel Corporation.
|
||||
@ -19,65 +18,57 @@
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Written by: Chris Lord <chris@openedhand.com>
|
||||
* Port to St by: Robert Staudinger <robsta@openedhand.com>
|
||||
* Port to Nbtk by: Robert Staudinger <robsta@openedhand.com>
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:st-scroll-bar
|
||||
* @short_description: a user interface element to control scrollable areas.
|
||||
*
|
||||
* The #StScrollBar allows users to scroll scrollable actors, either by
|
||||
* the step or page amount, or by manually dragging the handle.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
#include "st-scroll-bar.h"
|
||||
#include "st-bin.h"
|
||||
#include "st-marshal.h"
|
||||
#include "st-enum-types.h"
|
||||
#include "st-private.h"
|
||||
#include "st-button.h"
|
||||
#include "nbtk-scroll-bar.h"
|
||||
#include "nbtk-bin.h"
|
||||
#include "nbtk-marshal.h"
|
||||
#include "nbtk-enum-types.h"
|
||||
#include "nbtk-private.h"
|
||||
#include "nbtk-button.h"
|
||||
|
||||
G_DEFINE_TYPE (StScrollBar, st_scroll_bar, ST_TYPE_BIN)
|
||||
G_DEFINE_TYPE (NbtkScrollBar, nbtk_scroll_bar, NBTK_TYPE_BIN)
|
||||
|
||||
#define ST_SCROLL_BAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ST_TYPE_SCROLL_BAR, StScrollBarPrivate))
|
||||
#define NBTK_SCROLL_BAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NBTK_TYPE_SCROLL_BAR, NbtkScrollBarPrivate))
|
||||
|
||||
#define PAGING_INITIAL_REPEAT_TIMEOUT 500
|
||||
#define PAGING_SUBSEQUENT_REPEAT_TIMEOUT 200
|
||||
|
||||
struct _StScrollBarPrivate
|
||||
struct _NbtkScrollBarPrivate
|
||||
{
|
||||
StAdjustment *adjustment;
|
||||
NbtkAdjustment *adjustment;
|
||||
|
||||
gulong capture_handler;
|
||||
gfloat x_origin;
|
||||
gfloat y_origin;
|
||||
gulong capture_handler;
|
||||
gfloat x_origin;
|
||||
gfloat y_origin;
|
||||
|
||||
ClutterActor *bw_stepper;
|
||||
ClutterActor *fw_stepper;
|
||||
ClutterActor *trough;
|
||||
ClutterActor *handle;
|
||||
ClutterActor *bw_stepper;
|
||||
ClutterActor *fw_stepper;
|
||||
ClutterActor *trough;
|
||||
ClutterActor *handle;
|
||||
|
||||
gfloat move_x;
|
||||
gfloat move_y;
|
||||
gfloat move_x;
|
||||
gfloat move_y;
|
||||
|
||||
/* Trough-click handling. */
|
||||
enum { NONE, UP, DOWN } paging_direction;
|
||||
guint paging_source_id;
|
||||
guint paging_event_no;
|
||||
guint paging_source_id;
|
||||
guint paging_event_no;
|
||||
|
||||
gboolean stepper_forward;
|
||||
guint stepper_source_id;
|
||||
gboolean stepper_forward;
|
||||
guint stepper_source_id;
|
||||
|
||||
ClutterAnimation *paging_animation;
|
||||
ClutterAnimation *paging_animation;
|
||||
|
||||
gboolean vertical;
|
||||
gboolean vertical;
|
||||
};
|
||||
|
||||
enum
|
||||
@ -101,15 +92,15 @@ static guint signals[LAST_SIGNAL] = { 0, };
|
||||
static gboolean
|
||||
handle_button_press_event_cb (ClutterActor *actor,
|
||||
ClutterButtonEvent *event,
|
||||
StScrollBar *bar);
|
||||
NbtkScrollBar *bar);
|
||||
|
||||
static void
|
||||
st_scroll_bar_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
nbtk_scroll_bar_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StScrollBarPrivate *priv = ST_SCROLL_BAR (gobject)->priv;
|
||||
NbtkScrollBarPrivate *priv = NBTK_SCROLL_BAR (gobject)->priv;
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
@ -128,17 +119,17 @@ st_scroll_bar_get_property (GObject *gobject,
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_bar_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
nbtk_scroll_bar_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StScrollBar *bar = ST_SCROLL_BAR (gobject);
|
||||
NbtkScrollBar *bar = NBTK_SCROLL_BAR (gobject);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ADJUSTMENT:
|
||||
st_scroll_bar_set_adjustment (bar, g_value_get_object (value));
|
||||
nbtk_scroll_bar_set_adjustment (bar, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_VERTICAL:
|
||||
@ -171,13 +162,13 @@ st_scroll_bar_set_property (GObject *gobject,
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_bar_dispose (GObject *gobject)
|
||||
nbtk_scroll_bar_dispose (GObject *gobject)
|
||||
{
|
||||
StScrollBar *bar = ST_SCROLL_BAR (gobject);
|
||||
StScrollBarPrivate *priv = bar->priv;
|
||||
NbtkScrollBar *bar = NBTK_SCROLL_BAR (gobject);
|
||||
NbtkScrollBarPrivate *priv = bar->priv;
|
||||
|
||||
if (priv->adjustment)
|
||||
st_scroll_bar_set_adjustment (bar, NULL);
|
||||
nbtk_scroll_bar_set_adjustment (bar, NULL);
|
||||
|
||||
if (priv->handle)
|
||||
{
|
||||
@ -197,15 +188,15 @@ st_scroll_bar_dispose (GObject *gobject)
|
||||
clutter_actor_unparent (priv->trough);
|
||||
priv->trough = NULL;
|
||||
|
||||
G_OBJECT_CLASS (st_scroll_bar_parent_class)->dispose (gobject);
|
||||
G_OBJECT_CLASS (nbtk_scroll_bar_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_bar_paint (ClutterActor *actor)
|
||||
nbtk_scroll_bar_paint (ClutterActor *actor)
|
||||
{
|
||||
StScrollBarPrivate *priv = ST_SCROLL_BAR (actor)->priv;
|
||||
NbtkScrollBarPrivate *priv = NBTK_SCROLL_BAR (actor)->priv;
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_scroll_bar_parent_class)->paint (actor);
|
||||
CLUTTER_ACTOR_CLASS (nbtk_scroll_bar_parent_class)->paint (actor);
|
||||
|
||||
clutter_actor_paint (priv->bw_stepper);
|
||||
|
||||
@ -218,12 +209,12 @@ st_scroll_bar_paint (ClutterActor *actor)
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_bar_pick (ClutterActor *actor,
|
||||
const ClutterColor *pick_color)
|
||||
nbtk_scroll_bar_pick (ClutterActor *actor,
|
||||
const ClutterColor *pick_color)
|
||||
{
|
||||
StScrollBarPrivate *priv = ST_SCROLL_BAR (actor)->priv;
|
||||
NbtkScrollBarPrivate *priv = NBTK_SCROLL_BAR (actor)->priv;
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_scroll_bar_parent_class)->pick (actor, pick_color);
|
||||
CLUTTER_ACTOR_CLASS (nbtk_scroll_bar_parent_class)->pick (actor, pick_color);
|
||||
|
||||
clutter_actor_paint (priv->bw_stepper);
|
||||
clutter_actor_paint (priv->fw_stepper);
|
||||
@ -234,11 +225,11 @@ st_scroll_bar_pick (ClutterActor *actor,
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_bar_map (ClutterActor *actor)
|
||||
nbtk_scroll_bar_map (ClutterActor *actor)
|
||||
{
|
||||
StScrollBarPrivate *priv = ST_SCROLL_BAR (actor)->priv;
|
||||
NbtkScrollBarPrivate *priv = NBTK_SCROLL_BAR (actor)->priv;
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_scroll_bar_parent_class)->map (actor);
|
||||
CLUTTER_ACTOR_CLASS (nbtk_scroll_bar_parent_class)->map (actor);
|
||||
|
||||
clutter_actor_map (priv->bw_stepper);
|
||||
clutter_actor_map (priv->fw_stepper);
|
||||
@ -249,11 +240,11 @@ st_scroll_bar_map (ClutterActor *actor)
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_bar_unmap (ClutterActor *actor)
|
||||
nbtk_scroll_bar_unmap (ClutterActor *actor)
|
||||
{
|
||||
StScrollBarPrivate *priv = ST_SCROLL_BAR (actor)->priv;
|
||||
NbtkScrollBarPrivate *priv = NBTK_SCROLL_BAR (actor)->priv;
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_scroll_bar_parent_class)->unmap (actor);
|
||||
CLUTTER_ACTOR_CLASS (nbtk_scroll_bar_parent_class)->unmap (actor);
|
||||
|
||||
clutter_actor_unmap (priv->bw_stepper);
|
||||
clutter_actor_unmap (priv->fw_stepper);
|
||||
@ -264,20 +255,20 @@ st_scroll_bar_unmap (ClutterActor *actor)
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_bar_allocate (ClutterActor *actor,
|
||||
const ClutterActorBox *box,
|
||||
ClutterAllocationFlags flags)
|
||||
nbtk_scroll_bar_allocate (ClutterActor *actor,
|
||||
const ClutterActorBox *box,
|
||||
ClutterAllocationFlags flags)
|
||||
{
|
||||
StScrollBarPrivate *priv = ST_SCROLL_BAR (actor)->priv;
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
||||
NbtkScrollBarPrivate *priv = NBTK_SCROLL_BAR (actor)->priv;
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (actor));
|
||||
ClutterActorBox content_box, bw_box, fw_box, trough_box;
|
||||
gfloat stepper_size;
|
||||
|
||||
/* Chain up */
|
||||
CLUTTER_ACTOR_CLASS (st_scroll_bar_parent_class)->
|
||||
allocate (actor, box, flags);
|
||||
CLUTTER_ACTOR_CLASS (nbtk_scroll_bar_parent_class)->
|
||||
allocate (actor, box, flags);
|
||||
|
||||
st_theme_node_get_content_box (theme_node, box, &content_box);
|
||||
shell_theme_node_get_content_box (theme_node, box, &content_box);
|
||||
|
||||
if (priv->vertical)
|
||||
{
|
||||
@ -334,18 +325,18 @@ st_scroll_bar_allocate (ClutterActor *actor,
|
||||
|
||||
if (priv->adjustment)
|
||||
{
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
||||
float handle_size, position, avail_size;
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (actor));
|
||||
gfloat handle_size, position, avail_size;
|
||||
gdouble value, lower, upper, page_size, increment, min_size, max_size;
|
||||
ClutterActorBox handle_box = { 0, };
|
||||
|
||||
st_adjustment_get_values (priv->adjustment,
|
||||
&value,
|
||||
&lower,
|
||||
&upper,
|
||||
NULL,
|
||||
NULL,
|
||||
&page_size);
|
||||
nbtk_adjustment_get_values (priv->adjustment,
|
||||
&value,
|
||||
&lower,
|
||||
&upper,
|
||||
NULL,
|
||||
NULL,
|
||||
&page_size);
|
||||
|
||||
if ((upper == lower)
|
||||
|| (page_size >= (upper - lower)))
|
||||
@ -354,9 +345,9 @@ st_scroll_bar_allocate (ClutterActor *actor,
|
||||
increment = page_size / (upper - lower);
|
||||
|
||||
min_size = 32.;
|
||||
st_theme_node_get_length (theme_node, "min-size", FALSE, &min_size);
|
||||
shell_theme_node_get_length (theme_node, "min-size", FALSE, &min_size);
|
||||
max_size = G_MAXINT16;
|
||||
st_theme_node_get_length (theme_node, "max-size", FALSE, &max_size);
|
||||
shell_theme_node_get_length (theme_node, "max-size", FALSE, &max_size);
|
||||
|
||||
if (upper - lower - page_size <= 0)
|
||||
position = 0;
|
||||
@ -377,7 +368,7 @@ st_scroll_bar_allocate (ClutterActor *actor,
|
||||
}
|
||||
else
|
||||
{
|
||||
avail_size = content_box.x2 - content_box.x1 - stepper_size * 2;
|
||||
avail_size = content_box.x2 - content_box.x1 - stepper_size * 2;
|
||||
handle_size = increment * avail_size;
|
||||
handle_size = CLAMP (handle_size, min_size, max_size);
|
||||
|
||||
@ -401,44 +392,44 @@ st_scroll_bar_allocate (ClutterActor *actor,
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_bar_style_changed (StWidget *widget)
|
||||
nbtk_scroll_bar_style_changed (NbtkWidget *widget)
|
||||
{
|
||||
StScrollBarPrivate *priv = ST_SCROLL_BAR (widget)->priv;
|
||||
NbtkScrollBarPrivate *priv = NBTK_SCROLL_BAR (widget)->priv;
|
||||
|
||||
st_widget_style_changed (ST_WIDGET (priv->bw_stepper));
|
||||
st_widget_style_changed (ST_WIDGET (priv->fw_stepper));
|
||||
st_widget_style_changed (ST_WIDGET (priv->trough));
|
||||
st_widget_style_changed (ST_WIDGET (priv->handle));
|
||||
nbtk_widget_style_changed (NBTK_WIDGET (priv->bw_stepper));
|
||||
nbtk_widget_style_changed (NBTK_WIDGET (priv->fw_stepper));
|
||||
nbtk_widget_style_changed (NBTK_WIDGET (priv->trough));
|
||||
nbtk_widget_style_changed (NBTK_WIDGET (priv->handle));
|
||||
|
||||
ST_WIDGET_CLASS (st_scroll_bar_parent_class)->style_changed (widget);
|
||||
NBTK_WIDGET_CLASS (nbtk_scroll_bar_parent_class)->style_changed (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
bar_reactive_notify_cb (GObject *gobject,
|
||||
bar_reactive_notify_cb (GObject *gobject,
|
||||
GParamSpec *arg1,
|
||||
gpointer user_data)
|
||||
gpointer user_data)
|
||||
{
|
||||
StScrollBar *bar = ST_SCROLL_BAR (gobject);
|
||||
NbtkScrollBar *bar = NBTK_SCROLL_BAR (gobject);
|
||||
|
||||
clutter_actor_set_reactive (bar->priv->handle,
|
||||
clutter_actor_get_reactive (CLUTTER_ACTOR (bar)));
|
||||
}
|
||||
|
||||
static GObject*
|
||||
st_scroll_bar_constructor (GType type,
|
||||
guint n_properties,
|
||||
GObjectConstructParam *properties)
|
||||
nbtk_scroll_bar_constructor (GType type,
|
||||
guint n_properties,
|
||||
GObjectConstructParam *properties)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GObject *obj;
|
||||
StScrollBar *bar;
|
||||
StScrollBarPrivate *priv;
|
||||
GObjectClass *gobject_class;
|
||||
GObject *obj;
|
||||
NbtkScrollBar *bar;
|
||||
NbtkScrollBarPrivate *priv;
|
||||
|
||||
gobject_class = G_OBJECT_CLASS (st_scroll_bar_parent_class);
|
||||
gobject_class = G_OBJECT_CLASS (nbtk_scroll_bar_parent_class);
|
||||
obj = gobject_class->constructor (type, n_properties, properties);
|
||||
|
||||
bar = ST_SCROLL_BAR (obj);
|
||||
priv = ST_SCROLL_BAR_GET_PRIVATE (bar);
|
||||
bar = NBTK_SCROLL_BAR (obj);
|
||||
priv = NBTK_SCROLL_BAR_GET_PRIVATE (bar);
|
||||
|
||||
g_signal_connect (bar, "notify::reactive",
|
||||
G_CALLBACK (bar_reactive_notify_cb), NULL);
|
||||
@ -447,10 +438,10 @@ st_scroll_bar_constructor (GType type,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
st_scroll_bar_scroll_event (ClutterActor *actor,
|
||||
ClutterScrollEvent *event)
|
||||
nbtk_scroll_bar_scroll_event (ClutterActor *actor,
|
||||
ClutterScrollEvent *event)
|
||||
{
|
||||
StScrollBarPrivate *priv = ST_SCROLL_BAR (actor)->priv;
|
||||
NbtkScrollBarPrivate *priv = NBTK_SCROLL_BAR (actor)->priv;
|
||||
gdouble lower, step, upper, value;
|
||||
|
||||
if (priv->adjustment)
|
||||
@ -469,70 +460,70 @@ st_scroll_bar_scroll_event (ClutterActor *actor,
|
||||
|
||||
switch (event->direction)
|
||||
{
|
||||
case CLUTTER_SCROLL_UP:
|
||||
case CLUTTER_SCROLL_LEFT:
|
||||
if (value == lower)
|
||||
return FALSE;
|
||||
else
|
||||
st_adjustment_set_value (priv->adjustment, value - step);
|
||||
break;
|
||||
case CLUTTER_SCROLL_DOWN:
|
||||
case CLUTTER_SCROLL_RIGHT:
|
||||
if (value == upper)
|
||||
return FALSE;
|
||||
else
|
||||
st_adjustment_set_value (priv->adjustment, value + step);
|
||||
break;
|
||||
case CLUTTER_SCROLL_UP:
|
||||
case CLUTTER_SCROLL_LEFT:
|
||||
if (value == lower)
|
||||
return FALSE;
|
||||
else
|
||||
nbtk_adjustment_set_value (priv->adjustment, value - step);
|
||||
break;
|
||||
case CLUTTER_SCROLL_DOWN:
|
||||
case CLUTTER_SCROLL_RIGHT:
|
||||
if (value == upper)
|
||||
return FALSE;
|
||||
else
|
||||
nbtk_adjustment_set_value (priv->adjustment, value + step);
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_bar_class_init (StScrollBarClass *klass)
|
||||
nbtk_scroll_bar_class_init (NbtkScrollBarClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
||||
StWidgetClass *widget_class = ST_WIDGET_CLASS (klass);
|
||||
NbtkWidgetClass *widget_class = NBTK_WIDGET_CLASS (klass);
|
||||
GParamSpec *pspec;
|
||||
|
||||
g_type_class_add_private (klass, sizeof (StScrollBarPrivate));
|
||||
g_type_class_add_private (klass, sizeof (NbtkScrollBarPrivate));
|
||||
|
||||
object_class->get_property = st_scroll_bar_get_property;
|
||||
object_class->set_property = st_scroll_bar_set_property;
|
||||
object_class->dispose = st_scroll_bar_dispose;
|
||||
object_class->constructor = st_scroll_bar_constructor;
|
||||
object_class->get_property = nbtk_scroll_bar_get_property;
|
||||
object_class->set_property = nbtk_scroll_bar_set_property;
|
||||
object_class->dispose = nbtk_scroll_bar_dispose;
|
||||
object_class->constructor = nbtk_scroll_bar_constructor;
|
||||
|
||||
actor_class->allocate = st_scroll_bar_allocate;
|
||||
actor_class->paint = st_scroll_bar_paint;
|
||||
actor_class->pick = st_scroll_bar_pick;
|
||||
actor_class->scroll_event = st_scroll_bar_scroll_event;
|
||||
actor_class->map = st_scroll_bar_map;
|
||||
actor_class->unmap = st_scroll_bar_unmap;
|
||||
actor_class->allocate = nbtk_scroll_bar_allocate;
|
||||
actor_class->paint = nbtk_scroll_bar_paint;
|
||||
actor_class->pick = nbtk_scroll_bar_pick;
|
||||
actor_class->scroll_event = nbtk_scroll_bar_scroll_event;
|
||||
actor_class->map = nbtk_scroll_bar_map;
|
||||
actor_class->unmap = nbtk_scroll_bar_unmap;
|
||||
|
||||
widget_class->style_changed = st_scroll_bar_style_changed;
|
||||
widget_class->style_changed = nbtk_scroll_bar_style_changed;
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class,
|
||||
PROP_ADJUSTMENT,
|
||||
g_param_spec_object ("adjustment",
|
||||
"Adjustment",
|
||||
"The adjustment",
|
||||
ST_TYPE_ADJUSTMENT,
|
||||
ST_PARAM_READWRITE));
|
||||
(object_class,
|
||||
PROP_ADJUSTMENT,
|
||||
g_param_spec_object ("adjustment",
|
||||
"Adjustment",
|
||||
"The adjustment",
|
||||
NBTK_TYPE_ADJUSTMENT,
|
||||
NBTK_PARAM_READWRITE));
|
||||
|
||||
pspec = g_param_spec_boolean ("vertical",
|
||||
"Vertical Orientation",
|
||||
"Vertical Orientation",
|
||||
FALSE,
|
||||
ST_PARAM_READWRITE);
|
||||
NBTK_PARAM_READWRITE);
|
||||
g_object_class_install_property (object_class, PROP_VERTICAL, pspec);
|
||||
|
||||
signals[SCROLL_START] =
|
||||
g_signal_new ("scroll-start",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (StScrollBarClass, scroll_start),
|
||||
G_STRUCT_OFFSET (NbtkScrollBarClass, scroll_start),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
@ -541,18 +532,16 @@ st_scroll_bar_class_init (StScrollBarClass *klass)
|
||||
g_signal_new ("scroll-stop",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (StScrollBarClass, scroll_stop),
|
||||
G_STRUCT_OFFSET (NbtkScrollBarClass, scroll_stop),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
move_slider (StScrollBar *bar,
|
||||
gfloat x,
|
||||
gfloat y)
|
||||
move_slider (NbtkScrollBar *bar, gfloat x, gfloat y)
|
||||
{
|
||||
StScrollBarPrivate *priv = bar->priv;
|
||||
NbtkScrollBarPrivate *priv = bar->priv;
|
||||
gdouble position, lower, upper, page_size;
|
||||
gfloat ux, uy, pos, size;
|
||||
|
||||
@ -563,11 +552,11 @@ move_slider (StScrollBar *bar,
|
||||
return;
|
||||
|
||||
if (priv->vertical)
|
||||
size = clutter_actor_get_height (priv->trough)
|
||||
- clutter_actor_get_height (priv->handle);
|
||||
size = clutter_actor_get_height (priv->trough)
|
||||
- clutter_actor_get_height (priv->handle);
|
||||
else
|
||||
size = clutter_actor_get_width (priv->trough)
|
||||
- clutter_actor_get_width (priv->handle);
|
||||
size = clutter_actor_get_width (priv->trough)
|
||||
- clutter_actor_get_width (priv->handle);
|
||||
|
||||
if (size == 0)
|
||||
return;
|
||||
@ -578,44 +567,44 @@ move_slider (StScrollBar *bar,
|
||||
pos = ux - priv->x_origin;
|
||||
pos = CLAMP (pos, 0, size);
|
||||
|
||||
st_adjustment_get_values (priv->adjustment,
|
||||
NULL,
|
||||
&lower,
|
||||
&upper,
|
||||
NULL,
|
||||
NULL,
|
||||
&page_size);
|
||||
nbtk_adjustment_get_values (priv->adjustment,
|
||||
NULL,
|
||||
&lower,
|
||||
&upper,
|
||||
NULL,
|
||||
NULL,
|
||||
&page_size);
|
||||
|
||||
position = ((pos / size)
|
||||
* (upper - lower - page_size))
|
||||
+ lower;
|
||||
* (upper - lower - page_size))
|
||||
+ lower;
|
||||
|
||||
st_adjustment_set_value (priv->adjustment, position);
|
||||
nbtk_adjustment_set_value (priv->adjustment, position);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
handle_capture_event_cb (ClutterActor *trough,
|
||||
ClutterEvent *event,
|
||||
StScrollBar *bar)
|
||||
handle_capture_event_cb (ClutterActor *trough,
|
||||
ClutterEvent *event,
|
||||
NbtkScrollBar *bar)
|
||||
{
|
||||
if (clutter_event_type (event) == CLUTTER_MOTION)
|
||||
{
|
||||
move_slider (bar,
|
||||
((ClutterMotionEvent*) event)->x,
|
||||
((ClutterMotionEvent*) event)->y);
|
||||
((ClutterMotionEvent*)event)->x,
|
||||
((ClutterMotionEvent*)event)->y);
|
||||
}
|
||||
else if (clutter_event_type (event) == CLUTTER_BUTTON_RELEASE
|
||||
&& ((ClutterButtonEvent*) event)->button == 1)
|
||||
&& ((ClutterButtonEvent*)event)->button == 1)
|
||||
{
|
||||
ClutterActor *stage, *target;
|
||||
|
||||
stage = clutter_actor_get_stage(bar->priv->trough);
|
||||
|
||||
if (bar->priv->capture_handler)
|
||||
{
|
||||
g_signal_handler_disconnect (stage, bar->priv->capture_handler);
|
||||
bar->priv->capture_handler = 0;
|
||||
}
|
||||
{
|
||||
g_signal_handler_disconnect (stage, bar->priv->capture_handler);
|
||||
bar->priv->capture_handler = 0;
|
||||
}
|
||||
|
||||
clutter_set_motion_events_enabled (TRUE);
|
||||
g_signal_emit (bar, signals[SCROLL_STOP], 0);
|
||||
@ -628,7 +617,7 @@ handle_capture_event_cb (ClutterActor *trough,
|
||||
((ClutterButtonEvent*) event)->y);
|
||||
if (target != bar->priv->handle)
|
||||
{
|
||||
st_widget_set_style_pseudo_class ((StWidget*) bar->priv->handle, NULL);
|
||||
nbtk_widget_set_style_pseudo_class ((NbtkWidget*) bar->priv->handle, NULL);
|
||||
}
|
||||
|
||||
|
||||
@ -640,9 +629,9 @@ handle_capture_event_cb (ClutterActor *trough,
|
||||
static gboolean
|
||||
handle_button_press_event_cb (ClutterActor *actor,
|
||||
ClutterButtonEvent *event,
|
||||
StScrollBar *bar)
|
||||
NbtkScrollBar *bar)
|
||||
{
|
||||
StScrollBarPrivate *priv = bar->priv;
|
||||
NbtkScrollBarPrivate *priv = bar->priv;
|
||||
|
||||
if (event->button != 1)
|
||||
return FALSE;
|
||||
@ -662,25 +651,25 @@ handle_button_press_event_cb (ClutterActor *actor,
|
||||
clutter_set_motion_events_enabled (FALSE);
|
||||
|
||||
priv->capture_handler = g_signal_connect_after (
|
||||
clutter_actor_get_stage (priv->trough),
|
||||
"captured-event",
|
||||
G_CALLBACK (handle_capture_event_cb),
|
||||
bar);
|
||||
clutter_actor_get_stage (priv->trough),
|
||||
"captured-event",
|
||||
G_CALLBACK (handle_capture_event_cb),
|
||||
bar);
|
||||
g_signal_emit (bar, signals[SCROLL_START], 0);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
animation_completed_cb (ClutterAnimation *animation,
|
||||
StScrollBarPrivate *priv)
|
||||
animation_completed_cb (ClutterAnimation *animation,
|
||||
NbtkScrollBarPrivate *priv)
|
||||
{
|
||||
g_object_unref (priv->paging_animation);
|
||||
priv->paging_animation = NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
trough_paging_cb (StScrollBar *self)
|
||||
trough_paging_cb (NbtkScrollBar *self)
|
||||
{
|
||||
gfloat handle_pos, event_pos, tx, ty;
|
||||
gdouble value;
|
||||
@ -699,9 +688,9 @@ trough_paging_cb (StScrollBar *self)
|
||||
ret = FALSE;
|
||||
self->priv->paging_event_no = 1;
|
||||
self->priv->paging_source_id = g_timeout_add (
|
||||
PAGING_INITIAL_REPEAT_TIMEOUT,
|
||||
(GSourceFunc) trough_paging_cb,
|
||||
self);
|
||||
PAGING_INITIAL_REPEAT_TIMEOUT,
|
||||
(GSourceFunc) trough_paging_cb,
|
||||
self);
|
||||
}
|
||||
else if (self->priv->paging_event_no == 1)
|
||||
{
|
||||
@ -710,9 +699,9 @@ trough_paging_cb (StScrollBar *self)
|
||||
mode = CLUTTER_EASE_IN_CUBIC;
|
||||
self->priv->paging_event_no = 2;
|
||||
self->priv->paging_source_id = g_timeout_add (
|
||||
PAGING_SUBSEQUENT_REPEAT_TIMEOUT,
|
||||
(GSourceFunc) trough_paging_cb,
|
||||
self);
|
||||
PAGING_SUBSEQUENT_REPEAT_TIMEOUT,
|
||||
(GSourceFunc) trough_paging_cb,
|
||||
self);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -723,9 +712,9 @@ trough_paging_cb (StScrollBar *self)
|
||||
}
|
||||
|
||||
/* Do the scrolling */
|
||||
st_adjustment_get_values (self->priv->adjustment,
|
||||
&value, NULL, NULL,
|
||||
NULL, &page_increment, NULL);
|
||||
nbtk_adjustment_get_values (self->priv->adjustment,
|
||||
&value, NULL, NULL,
|
||||
NULL, &page_increment, NULL);
|
||||
|
||||
if (self->priv->vertical)
|
||||
handle_pos = clutter_actor_get_y (self->priv->handle);
|
||||
@ -777,7 +766,7 @@ trough_paging_cb (StScrollBar *self)
|
||||
}
|
||||
|
||||
/* FIXME: Creating a new animation for each scroll is probably not the best
|
||||
* idea, but it's a lot less involved than extenind the current animation */
|
||||
* idea, but it's a lot less involved than extenind the current animation */
|
||||
a = self->priv->paging_animation = g_object_new (CLUTTER_TYPE_ANIMATION,
|
||||
"object", self->priv->adjustment,
|
||||
"duration", PAGING_SUBSEQUENT_REPEAT_TIMEOUT,
|
||||
@ -797,7 +786,7 @@ trough_paging_cb (StScrollBar *self)
|
||||
static gboolean
|
||||
trough_button_press_event_cb (ClutterActor *actor,
|
||||
ClutterButtonEvent *event,
|
||||
StScrollBar *self)
|
||||
NbtkScrollBar *self)
|
||||
{
|
||||
g_return_val_if_fail (self, FALSE);
|
||||
|
||||
@ -819,7 +808,7 @@ trough_button_press_event_cb (ClutterActor *actor,
|
||||
static gboolean
|
||||
trough_button_release_event_cb (ClutterActor *actor,
|
||||
ClutterButtonEvent *event,
|
||||
StScrollBar *self)
|
||||
NbtkScrollBar *self)
|
||||
{
|
||||
if (event->button != 1)
|
||||
return FALSE;
|
||||
@ -834,9 +823,9 @@ trough_button_release_event_cb (ClutterActor *actor,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
trough_leave_event_cb (ClutterActor *actor,
|
||||
ClutterEvent *event,
|
||||
StScrollBar *self)
|
||||
trough_leave_event_cb (ClutterActor *actor,
|
||||
ClutterEvent *event,
|
||||
NbtkScrollBar *self)
|
||||
{
|
||||
if (self->priv->paging_source_id)
|
||||
{
|
||||
@ -856,8 +845,8 @@ stepper_animation_completed_cb (ClutterAnimation *a,
|
||||
}
|
||||
|
||||
static void
|
||||
stepper_move_on (StScrollBarPrivate *priv,
|
||||
gint mode)
|
||||
stepper_move_on (NbtkScrollBarPrivate *priv,
|
||||
gint mode)
|
||||
{
|
||||
ClutterAnimation *a;
|
||||
ClutterTimeline *t;
|
||||
@ -892,7 +881,7 @@ stepper_move_on (StScrollBarPrivate *priv,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
stepper_button_subsequent_timeout (StScrollBarPrivate *priv)
|
||||
stepper_button_subsequent_timeout (NbtkScrollBarPrivate *priv)
|
||||
{
|
||||
stepper_move_on (priv, CLUTTER_LINEAR);
|
||||
|
||||
@ -900,7 +889,7 @@ stepper_button_subsequent_timeout (StScrollBarPrivate *priv)
|
||||
}
|
||||
|
||||
static gboolean
|
||||
stepper_button_repeat_timeout (StScrollBarPrivate *priv)
|
||||
stepper_button_repeat_timeout (NbtkScrollBarPrivate *priv)
|
||||
{
|
||||
priv->stepper_source_id = 0;
|
||||
|
||||
@ -916,9 +905,9 @@ stepper_button_repeat_timeout (StScrollBarPrivate *priv)
|
||||
static gboolean
|
||||
stepper_button_press_event_cb (ClutterActor *actor,
|
||||
ClutterButtonEvent *event,
|
||||
StScrollBar *bar)
|
||||
NbtkScrollBar *bar)
|
||||
{
|
||||
StScrollBarPrivate *priv = bar->priv;
|
||||
NbtkScrollBarPrivate *priv = bar->priv;
|
||||
|
||||
if (event->button != 1)
|
||||
return FALSE;
|
||||
@ -939,9 +928,9 @@ stepper_button_press_event_cb (ClutterActor *actor,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
stepper_button_release_cb (ClutterActor *actor,
|
||||
ClutterButtonEvent *event,
|
||||
StScrollBar *self)
|
||||
stepper_button_release_cb (ClutterActor *actor,
|
||||
ClutterButtonEvent *event,
|
||||
NbtkScrollBar *self)
|
||||
{
|
||||
if (event->button != 1)
|
||||
return FALSE;
|
||||
@ -952,9 +941,9 @@ stepper_button_release_cb (ClutterActor *actor,
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_bar_notify_reactive (StScrollBar *self)
|
||||
nbtk_scroll_bar_notify_reactive (NbtkScrollBar *self)
|
||||
{
|
||||
StScrollBarPrivate *priv = self->priv;
|
||||
NbtkScrollBarPrivate *priv = self->priv;
|
||||
|
||||
gboolean reactive = CLUTTER_ACTOR_IS_REACTIVE (self);
|
||||
|
||||
@ -965,11 +954,11 @@ st_scroll_bar_notify_reactive (StScrollBar *self)
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_bar_init (StScrollBar *self)
|
||||
nbtk_scroll_bar_init (NbtkScrollBar *self)
|
||||
{
|
||||
self->priv = ST_SCROLL_BAR_GET_PRIVATE (self);
|
||||
self->priv = NBTK_SCROLL_BAR_GET_PRIVATE (self);
|
||||
|
||||
self->priv->bw_stepper = (ClutterActor *) st_button_new ();
|
||||
self->priv->bw_stepper = (ClutterActor *) nbtk_button_new ();
|
||||
clutter_actor_set_name (CLUTTER_ACTOR (self->priv->bw_stepper),
|
||||
"backward-stepper");
|
||||
clutter_actor_set_parent (CLUTTER_ACTOR (self->priv->bw_stepper),
|
||||
@ -979,7 +968,7 @@ st_scroll_bar_init (StScrollBar *self)
|
||||
g_signal_connect (self->priv->bw_stepper, "button-release-event",
|
||||
G_CALLBACK (stepper_button_release_cb), self);
|
||||
|
||||
self->priv->fw_stepper = (ClutterActor *) st_button_new ();
|
||||
self->priv->fw_stepper = (ClutterActor *) nbtk_button_new ();
|
||||
clutter_actor_set_name (CLUTTER_ACTOR (self->priv->fw_stepper),
|
||||
"forward-stepper");
|
||||
clutter_actor_set_parent (CLUTTER_ACTOR (self->priv->fw_stepper),
|
||||
@ -989,7 +978,7 @@ st_scroll_bar_init (StScrollBar *self)
|
||||
g_signal_connect (self->priv->fw_stepper, "button-release-event",
|
||||
G_CALLBACK (stepper_button_release_cb), self);
|
||||
|
||||
self->priv->trough = (ClutterActor *) st_bin_new ();
|
||||
self->priv->trough = (ClutterActor *) nbtk_bin_new ();
|
||||
clutter_actor_set_reactive ((ClutterActor *) self->priv->trough, TRUE);
|
||||
clutter_actor_set_name (CLUTTER_ACTOR (self->priv->trough), "trough");
|
||||
clutter_actor_set_parent (CLUTTER_ACTOR (self->priv->trough),
|
||||
@ -1001,7 +990,7 @@ st_scroll_bar_init (StScrollBar *self)
|
||||
g_signal_connect (self->priv->trough, "leave-event",
|
||||
G_CALLBACK (trough_leave_event_cb), self);
|
||||
|
||||
self->priv->handle = (ClutterActor *) st_button_new ();
|
||||
self->priv->handle = (ClutterActor *) nbtk_button_new ();
|
||||
clutter_actor_set_name (CLUTTER_ACTOR (self->priv->handle), "hhandle");
|
||||
clutter_actor_set_parent (CLUTTER_ACTOR (self->priv->handle),
|
||||
self->priv->trough);
|
||||
@ -1011,24 +1000,24 @@ st_scroll_bar_init (StScrollBar *self)
|
||||
clutter_actor_set_reactive (CLUTTER_ACTOR (self), TRUE);
|
||||
|
||||
g_signal_connect (self, "notify::reactive",
|
||||
G_CALLBACK (st_scroll_bar_notify_reactive), NULL);
|
||||
G_CALLBACK (nbtk_scroll_bar_notify_reactive), NULL);
|
||||
}
|
||||
|
||||
StWidget *
|
||||
st_scroll_bar_new (StAdjustment *adjustment)
|
||||
NbtkWidget *
|
||||
nbtk_scroll_bar_new (NbtkAdjustment *adjustment)
|
||||
{
|
||||
return g_object_new (ST_TYPE_SCROLL_BAR,
|
||||
return g_object_new (NBTK_TYPE_SCROLL_BAR,
|
||||
"adjustment", adjustment,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
st_scroll_bar_set_adjustment (StScrollBar *bar,
|
||||
StAdjustment *adjustment)
|
||||
nbtk_scroll_bar_set_adjustment (NbtkScrollBar *bar,
|
||||
NbtkAdjustment *adjustment)
|
||||
{
|
||||
StScrollBarPrivate *priv;
|
||||
NbtkScrollBarPrivate *priv;
|
||||
|
||||
g_return_if_fail (ST_IS_SCROLL_BAR (bar));
|
||||
g_return_if_fail (NBTK_IS_SCROLL_BAR (bar));
|
||||
|
||||
priv = bar->priv;
|
||||
if (priv->adjustment)
|
||||
@ -1051,27 +1040,26 @@ st_scroll_bar_set_adjustment (StScrollBar *bar,
|
||||
G_CALLBACK (clutter_actor_queue_relayout),
|
||||
bar);
|
||||
g_signal_connect_swapped (priv->adjustment, "changed",
|
||||
G_CALLBACK (clutter_actor_queue_relayout),
|
||||
bar);
|
||||
G_CALLBACK (clutter_actor_queue_relayout),
|
||||
bar);
|
||||
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (bar));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* st_scroll_bar_get_adjustment:
|
||||
* @bar: a #StScrollbar
|
||||
* nbtk_scroll_bar_get_adjustment:
|
||||
* @bar: a #NbtkScrollbar
|
||||
*
|
||||
* Gets the adjustment object that stores the current position
|
||||
* of the scrollbar.
|
||||
*
|
||||
* Return value: (transfer none): the adjustment
|
||||
*/
|
||||
StAdjustment *
|
||||
st_scroll_bar_get_adjustment (StScrollBar *bar)
|
||||
NbtkAdjustment *
|
||||
nbtk_scroll_bar_get_adjustment (NbtkScrollBar *bar)
|
||||
{
|
||||
g_return_val_if_fail (ST_IS_SCROLL_BAR (bar), NULL);
|
||||
g_return_val_if_fail (NBTK_IS_SCROLL_BAR (bar), NULL);
|
||||
|
||||
return bar->priv->adjustment;
|
||||
}
|
||||
|
81
src/nbtk/nbtk-scroll-bar.h
Normal file
81
src/nbtk/nbtk-scroll-bar.h
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* nbtk-scroll-bar.h: Scroll bar actor
|
||||
*
|
||||
* Copyright 2008 OpenedHand
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Written by: Chris Lord <chris@openedhand.com>
|
||||
* Port to Nbtk by: Robert Staudinger <robsta@openedhand.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(NBTK_H_INSIDE) && !defined(NBTK_COMPILATION)
|
||||
#error "Only <nbtk/nbtk.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef __NBTK_SCROLL_BAR_H__
|
||||
#define __NBTK_SCROLL_BAR_H__
|
||||
|
||||
#include <nbtk/nbtk-adjustment.h>
|
||||
#include <nbtk/nbtk-bin.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NBTK_TYPE_SCROLL_BAR (nbtk_scroll_bar_get_type())
|
||||
#define NBTK_SCROLL_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NBTK_TYPE_SCROLL_BAR, NbtkScrollBar))
|
||||
#define NBTK_IS_SCROLL_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NBTK_TYPE_SCROLL_BAR))
|
||||
#define NBTK_SCROLL_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NBTK_TYPE_SCROLL_BAR, NbtkScrollBarClass))
|
||||
#define NBTK_IS_SCROLL_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NBTK_TYPE_SCROLL_BAR))
|
||||
#define NBTK_SCROLL_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NBTK_TYPE_SCROLL_BAR, NbtkScrollBarClass))
|
||||
|
||||
typedef struct _NbtkScrollBar NbtkScrollBar;
|
||||
typedef struct _NbtkScrollBarPrivate NbtkScrollBarPrivate;
|
||||
typedef struct _NbtkScrollBarClass NbtkScrollBarClass;
|
||||
|
||||
/**
|
||||
* NbtkScrollBar:
|
||||
*
|
||||
* The contents of this structure are private and should only be accessed
|
||||
* through the public API.
|
||||
*/
|
||||
struct _NbtkScrollBar
|
||||
{
|
||||
/*< private >*/
|
||||
NbtkBin parent_instance;
|
||||
|
||||
NbtkScrollBarPrivate *priv;
|
||||
};
|
||||
|
||||
struct _NbtkScrollBarClass
|
||||
{
|
||||
NbtkBinClass parent_class;
|
||||
|
||||
/* signals */
|
||||
void (*scroll_start) (NbtkScrollBar *bar);
|
||||
void (*scroll_stop) (NbtkScrollBar *bar);
|
||||
};
|
||||
|
||||
GType nbtk_scroll_bar_get_type (void) G_GNUC_CONST;
|
||||
|
||||
NbtkWidget * nbtk_scroll_bar_new (NbtkAdjustment *adjustment);
|
||||
void nbtk_scroll_bar_set_adjustment (NbtkScrollBar *bar,
|
||||
NbtkAdjustment *adjustment);
|
||||
NbtkAdjustment *nbtk_scroll_bar_get_adjustment (NbtkScrollBar *bar);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NBTK_SCROLL_BAR_H__ */
|
829
src/nbtk/nbtk-scroll-view.c
Normal file
829
src/nbtk/nbtk-scroll-view.c
Normal file
@ -0,0 +1,829 @@
|
||||
/*
|
||||
* nbtk-scroll-view.h: Container with scroll-bars
|
||||
*
|
||||
* Copyright 2008 OpenedHand
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Written by: Chris Lord <chris@openedhand.com>
|
||||
* Port to Nbtk by: Robert Staudinger <robsta@openedhand.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nbtk-scroll-view.h"
|
||||
#include "nbtk-marshal.h"
|
||||
#include "nbtk-scroll-bar.h"
|
||||
#include "nbtk-scrollable.h"
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
static void clutter_container_iface_init (ClutterContainerIface *iface);
|
||||
|
||||
static ClutterContainerIface *nbtk_scroll_view_parent_iface = NULL;
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NbtkScrollView, nbtk_scroll_view, NBTK_TYPE_BIN,
|
||||
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_CONTAINER,
|
||||
clutter_container_iface_init))
|
||||
|
||||
#define SCROLL_VIEW_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
|
||||
NBTK_TYPE_SCROLL_VIEW, \
|
||||
NbtkScrollViewPrivate))
|
||||
|
||||
/* Default width (or height - the narrow dimension) for the scrollbars*/
|
||||
#define DEFAULT_SCROLLBAR_WIDTH 24
|
||||
|
||||
struct _NbtkScrollViewPrivate
|
||||
{
|
||||
/* a pointer to the child; this is actually stored
|
||||
* inside NbtkBin:child, but we keep it to avoid
|
||||
* calling nbtk_bin_get_child() every time we need it
|
||||
*/
|
||||
ClutterActor *child;
|
||||
|
||||
ClutterActor *hscroll;
|
||||
ClutterActor *vscroll;
|
||||
|
||||
gfloat row_size;
|
||||
gfloat column_size;
|
||||
|
||||
gboolean row_size_set : 1;
|
||||
gboolean column_size_set : 1;
|
||||
guint mouse_scroll : 1;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
|
||||
PROP_HSCROLL,
|
||||
PROP_VSCROLL,
|
||||
PROP_MOUSE_SCROLL
|
||||
};
|
||||
|
||||
static void
|
||||
nbtk_scroll_view_get_property (GObject *object, guint property_id,
|
||||
GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NbtkScrollViewPrivate *priv = ((NbtkScrollView *)object)->priv;
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_HSCROLL :
|
||||
g_value_set_object (value, priv->hscroll);
|
||||
break;
|
||||
case PROP_VSCROLL :
|
||||
g_value_set_object (value, priv->vscroll);
|
||||
break;
|
||||
case PROP_MOUSE_SCROLL:
|
||||
g_value_set_boolean (value, priv->mouse_scroll);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_scroll_view_set_property (GObject *object, guint property_id,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_MOUSE_SCROLL:
|
||||
nbtk_scroll_view_set_mouse_scrolling ((NbtkScrollView *) object,
|
||||
g_value_get_boolean (value));
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_scroll_view_dispose (GObject *object)
|
||||
{
|
||||
NbtkScrollViewPrivate *priv = NBTK_SCROLL_VIEW (object)->priv;
|
||||
|
||||
priv->child = NULL;
|
||||
|
||||
if (priv->vscroll)
|
||||
{
|
||||
clutter_actor_unparent (priv->vscroll);
|
||||
priv->vscroll = NULL;
|
||||
}
|
||||
|
||||
if (priv->hscroll)
|
||||
{
|
||||
clutter_actor_unparent (priv->hscroll);
|
||||
priv->hscroll = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (nbtk_scroll_view_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_scroll_view_finalize (GObject *object)
|
||||
{
|
||||
G_OBJECT_CLASS (nbtk_scroll_view_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_scroll_view_paint (ClutterActor *actor)
|
||||
{
|
||||
NbtkScrollViewPrivate *priv = NBTK_SCROLL_VIEW (actor)->priv;
|
||||
|
||||
/* NbtkBin will paint the child */
|
||||
CLUTTER_ACTOR_CLASS (nbtk_scroll_view_parent_class)->paint (actor);
|
||||
|
||||
/* paint our custom children */
|
||||
if (CLUTTER_ACTOR_IS_VISIBLE (priv->hscroll))
|
||||
clutter_actor_paint (priv->hscroll);
|
||||
if (CLUTTER_ACTOR_IS_VISIBLE (priv->vscroll))
|
||||
clutter_actor_paint (priv->vscroll);
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_scroll_view_pick (ClutterActor *actor, const ClutterColor *color)
|
||||
{
|
||||
NbtkScrollViewPrivate *priv = NBTK_SCROLL_VIEW (actor)->priv;
|
||||
|
||||
/* Chain up so we get a bounding box pained (if we are reactive) */
|
||||
CLUTTER_ACTOR_CLASS (nbtk_scroll_view_parent_class)->pick (actor, color);
|
||||
|
||||
/* paint our custom children */
|
||||
if (CLUTTER_ACTOR_IS_VISIBLE (priv->hscroll))
|
||||
clutter_actor_paint (priv->hscroll);
|
||||
if (CLUTTER_ACTOR_IS_VISIBLE (priv->vscroll))
|
||||
clutter_actor_paint (priv->vscroll);
|
||||
}
|
||||
|
||||
static double
|
||||
get_scrollbar_width (NbtkScrollView *scroll_view)
|
||||
{
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (scroll_view));
|
||||
double result = DEFAULT_SCROLLBAR_WIDTH;
|
||||
|
||||
shell_theme_node_get_length (theme_node, "scrollbar-width", FALSE, &result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static double
|
||||
get_scrollbar_height (NbtkScrollView *scroll_view)
|
||||
{
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (scroll_view));
|
||||
double result = DEFAULT_SCROLLBAR_WIDTH;
|
||||
|
||||
shell_theme_node_get_length (theme_node, "scrollbar-height", FALSE, &result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_scroll_view_get_preferred_width (ClutterActor *actor,
|
||||
gfloat for_height,
|
||||
gfloat *min_width_p,
|
||||
gfloat *natural_width_p)
|
||||
{
|
||||
NbtkScrollViewPrivate *priv = NBTK_SCROLL_VIEW (actor)->priv;
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (actor));
|
||||
|
||||
if (!priv->child)
|
||||
return;
|
||||
|
||||
shell_theme_node_adjust_for_height (theme_node, &for_height);
|
||||
|
||||
/* Our natural width is the natural width of the child */
|
||||
clutter_actor_get_preferred_width (priv->child,
|
||||
for_height,
|
||||
NULL,
|
||||
natural_width_p);
|
||||
|
||||
/* Add space for the scroll-bar if we can determine it will be necessary */
|
||||
if ((for_height >= 0) && natural_width_p)
|
||||
{
|
||||
gfloat natural_height;
|
||||
|
||||
clutter_actor_get_preferred_height (priv->child, -1.0,
|
||||
NULL,
|
||||
&natural_height);
|
||||
if (for_height < natural_height)
|
||||
*natural_width_p += get_scrollbar_width (NBTK_SCROLL_VIEW (actor));
|
||||
}
|
||||
|
||||
if (min_width_p)
|
||||
*min_width_p = 0;
|
||||
|
||||
shell_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p);
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_scroll_view_get_preferred_height (ClutterActor *actor,
|
||||
gfloat for_width,
|
||||
gfloat *min_height_p,
|
||||
gfloat *natural_height_p)
|
||||
{
|
||||
NbtkScrollViewPrivate *priv = NBTK_SCROLL_VIEW (actor)->priv;
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (actor));
|
||||
|
||||
if (!priv->child)
|
||||
return;
|
||||
|
||||
shell_theme_node_adjust_for_width (theme_node, &for_width);
|
||||
|
||||
/* Our natural height is the natural height of the child */
|
||||
clutter_actor_get_preferred_height (priv->child,
|
||||
for_width,
|
||||
NULL,
|
||||
natural_height_p);
|
||||
|
||||
/* Add space for the scroll-bar if we can determine it will be necessary */
|
||||
if ((for_width >= 0) && natural_height_p)
|
||||
{
|
||||
gfloat natural_width;
|
||||
|
||||
clutter_actor_get_preferred_width (priv->child, -1.0,
|
||||
NULL,
|
||||
&natural_width);
|
||||
if (for_width < natural_width)
|
||||
*natural_height_p += get_scrollbar_height (NBTK_SCROLL_VIEW (actor));
|
||||
}
|
||||
|
||||
if (min_height_p)
|
||||
*min_height_p = 0;
|
||||
|
||||
shell_theme_node_adjust_preferred_height (theme_node, min_height_p, natural_height_p);
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_scroll_view_allocate (ClutterActor *actor,
|
||||
const ClutterActorBox *box,
|
||||
ClutterAllocationFlags flags)
|
||||
{
|
||||
ClutterActorBox content_box, child_box;
|
||||
ClutterActorClass *parent_parent_class;
|
||||
gfloat avail_width, avail_height, sb_width, sb_height;
|
||||
|
||||
NbtkScrollViewPrivate *priv = NBTK_SCROLL_VIEW (actor)->priv;
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (actor));
|
||||
|
||||
/* Chain up to the parent's parent class
|
||||
*
|
||||
* We do this because we do not want NbtkBin to allocate the child, as we
|
||||
* give it a different allocation later, depending on whether the scrollbars
|
||||
* are visible
|
||||
*/
|
||||
parent_parent_class
|
||||
= g_type_class_peek_parent (nbtk_scroll_view_parent_class);
|
||||
|
||||
CLUTTER_ACTOR_CLASS (parent_parent_class)->
|
||||
allocate (actor, box, flags);
|
||||
|
||||
|
||||
shell_theme_node_get_content_box (theme_node, box, &content_box);
|
||||
|
||||
avail_width = content_box.x2 - content_box.x1;
|
||||
avail_height = content_box.y2 - content_box.y1;
|
||||
|
||||
sb_width = get_scrollbar_width (NBTK_SCROLL_VIEW (actor));
|
||||
sb_height = get_scrollbar_width (NBTK_SCROLL_VIEW (actor));
|
||||
|
||||
if (!CLUTTER_ACTOR_IS_VISIBLE (priv->vscroll))
|
||||
sb_width = 0;
|
||||
|
||||
if (!CLUTTER_ACTOR_IS_VISIBLE (priv->hscroll))
|
||||
sb_height = 0;
|
||||
|
||||
/* Vertical scrollbar */
|
||||
if (CLUTTER_ACTOR_IS_VISIBLE (priv->vscroll))
|
||||
{
|
||||
child_box.x1 = content_box.x2 - sb_width;
|
||||
child_box.y1 = content_box.y1;
|
||||
child_box.x2 = content_box.x2;
|
||||
child_box.y2 = content_box.y2 - sb_height;
|
||||
|
||||
clutter_actor_allocate (priv->vscroll, &child_box, flags);
|
||||
}
|
||||
|
||||
/* Horizontal scrollbar */
|
||||
if (CLUTTER_ACTOR_IS_VISIBLE (priv->hscroll))
|
||||
{
|
||||
child_box.x1 = content_box.x1;
|
||||
child_box.y1 = content_box.y2 - sb_height;
|
||||
child_box.x2 = content_box.x2 - sb_width;
|
||||
child_box.y2 = content_box.y2;
|
||||
|
||||
clutter_actor_allocate (priv->hscroll, &child_box, flags);
|
||||
}
|
||||
|
||||
|
||||
/* Child */
|
||||
child_box.x1 = content_box.x1;
|
||||
child_box.y1 = content_box.y1;
|
||||
child_box.x2 = content_box.x2 - sb_width;
|
||||
child_box.y2 = content_box.y2 - sb_height;
|
||||
|
||||
if (priv->child)
|
||||
clutter_actor_allocate (priv->child, &child_box, flags);
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_scroll_view_style_changed (NbtkWidget *widget)
|
||||
{
|
||||
NbtkScrollViewPrivate *priv = NBTK_SCROLL_VIEW (widget)->priv;
|
||||
|
||||
nbtk_widget_style_changed (NBTK_WIDGET (priv->hscroll));
|
||||
nbtk_widget_style_changed (NBTK_WIDGET (priv->vscroll));
|
||||
|
||||
NBTK_WIDGET_CLASS (nbtk_scroll_view_parent_class)->style_changed (widget);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
nbtk_scroll_view_scroll_event (ClutterActor *self,
|
||||
ClutterScrollEvent *event)
|
||||
{
|
||||
NbtkScrollViewPrivate *priv = NBTK_SCROLL_VIEW (self)->priv;
|
||||
gdouble lower, value, upper, step;
|
||||
NbtkAdjustment *vadjustment, *hadjustment;
|
||||
|
||||
/* don't handle scroll events if requested not to */
|
||||
if (!priv->mouse_scroll)
|
||||
return FALSE;
|
||||
|
||||
hadjustment = nbtk_scroll_bar_get_adjustment (NBTK_SCROLL_BAR(priv->hscroll));
|
||||
vadjustment = nbtk_scroll_bar_get_adjustment (NBTK_SCROLL_BAR(priv->vscroll));
|
||||
|
||||
switch (event->direction)
|
||||
{
|
||||
case CLUTTER_SCROLL_UP:
|
||||
case CLUTTER_SCROLL_DOWN:
|
||||
if (vadjustment)
|
||||
g_object_get (vadjustment,
|
||||
"lower", &lower,
|
||||
"step-increment", &step,
|
||||
"value", &value,
|
||||
"upper", &upper,
|
||||
NULL);
|
||||
else
|
||||
return FALSE;
|
||||
break;
|
||||
case CLUTTER_SCROLL_LEFT:
|
||||
case CLUTTER_SCROLL_RIGHT:
|
||||
if (vadjustment)
|
||||
g_object_get (hadjustment,
|
||||
"lower", &lower,
|
||||
"step-increment", &step,
|
||||
"value", &value,
|
||||
"upper", &upper,
|
||||
NULL);
|
||||
else
|
||||
return FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (event->direction)
|
||||
{
|
||||
case CLUTTER_SCROLL_UP:
|
||||
if (value == lower)
|
||||
return FALSE;
|
||||
else
|
||||
nbtk_adjustment_set_value (vadjustment, value - step);
|
||||
break;
|
||||
case CLUTTER_SCROLL_DOWN:
|
||||
if (value == upper)
|
||||
return FALSE;
|
||||
else
|
||||
nbtk_adjustment_set_value (vadjustment, value + step);
|
||||
break;
|
||||
case CLUTTER_SCROLL_LEFT:
|
||||
if (value == lower)
|
||||
return FALSE;
|
||||
else
|
||||
nbtk_adjustment_set_value (hadjustment, value - step);
|
||||
break;
|
||||
case CLUTTER_SCROLL_RIGHT:
|
||||
if (value == upper)
|
||||
return FALSE;
|
||||
else
|
||||
nbtk_adjustment_set_value (hadjustment, value + step);
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_scroll_view_class_init (NbtkScrollViewClass *klass)
|
||||
{
|
||||
GParamSpec *pspec;
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
||||
NbtkWidgetClass *widget_class = NBTK_WIDGET_CLASS (klass);
|
||||
|
||||
g_type_class_add_private (klass, sizeof (NbtkScrollViewPrivate));
|
||||
|
||||
object_class->get_property = nbtk_scroll_view_get_property;
|
||||
object_class->set_property = nbtk_scroll_view_set_property;
|
||||
object_class->dispose= nbtk_scroll_view_dispose;
|
||||
object_class->finalize = nbtk_scroll_view_finalize;
|
||||
|
||||
actor_class->paint = nbtk_scroll_view_paint;
|
||||
actor_class->pick = nbtk_scroll_view_pick;
|
||||
actor_class->get_preferred_width = nbtk_scroll_view_get_preferred_width;
|
||||
actor_class->get_preferred_height = nbtk_scroll_view_get_preferred_height;
|
||||
actor_class->allocate = nbtk_scroll_view_allocate;
|
||||
actor_class->scroll_event = nbtk_scroll_view_scroll_event;
|
||||
|
||||
widget_class->style_changed = nbtk_scroll_view_style_changed;
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_HSCROLL,
|
||||
g_param_spec_object ("hscroll",
|
||||
"NbtkScrollBar",
|
||||
"Horizontal scroll indicator",
|
||||
NBTK_TYPE_SCROLL_BAR,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_VSCROLL,
|
||||
g_param_spec_object ("vscroll",
|
||||
"NbtkScrollBar",
|
||||
"Vertical scroll indicator",
|
||||
NBTK_TYPE_SCROLL_BAR,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
pspec = g_param_spec_boolean ("enable-mouse-scrolling",
|
||||
"Enable Mouse Scrolling",
|
||||
"Enable automatic mouse wheel scrolling",
|
||||
TRUE,
|
||||
G_PARAM_READWRITE);
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_MOUSE_SCROLL,
|
||||
pspec);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
child_adjustment_changed_cb (NbtkAdjustment *adjustment,
|
||||
ClutterActor *bar)
|
||||
{
|
||||
NbtkScrollView *scroll;
|
||||
gdouble lower, upper, page_size;
|
||||
|
||||
scroll = NBTK_SCROLL_VIEW (clutter_actor_get_parent (bar));
|
||||
|
||||
/* Determine if this scroll-bar should be visible */
|
||||
nbtk_adjustment_get_values (adjustment, NULL,
|
||||
&lower, &upper,
|
||||
NULL, NULL,
|
||||
&page_size);
|
||||
|
||||
if ((upper - lower) > page_size)
|
||||
clutter_actor_show (bar);
|
||||
else
|
||||
clutter_actor_hide (bar);
|
||||
|
||||
/* Request a resize */
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (scroll));
|
||||
}
|
||||
|
||||
static void
|
||||
child_hadjustment_notify_cb (GObject *gobject,
|
||||
GParamSpec *arg1,
|
||||
gpointer user_data)
|
||||
{
|
||||
NbtkAdjustment *hadjust;
|
||||
|
||||
ClutterActor *actor = CLUTTER_ACTOR (gobject);
|
||||
NbtkScrollViewPrivate *priv = NBTK_SCROLL_VIEW (user_data)->priv;
|
||||
|
||||
hadjust = nbtk_scroll_bar_get_adjustment (NBTK_SCROLL_BAR(priv->hscroll));
|
||||
if (hadjust)
|
||||
g_signal_handlers_disconnect_by_func (hadjust,
|
||||
child_adjustment_changed_cb,
|
||||
priv->hscroll);
|
||||
|
||||
nbtk_scrollable_get_adjustments (NBTK_SCROLLABLE (actor), &hadjust, NULL);
|
||||
if (hadjust)
|
||||
{
|
||||
/* Force scroll step if neede. */
|
||||
if (priv->column_size_set)
|
||||
{
|
||||
g_object_set (hadjust,
|
||||
"step-increment", priv->column_size,
|
||||
NULL);
|
||||
}
|
||||
|
||||
nbtk_scroll_bar_set_adjustment (NBTK_SCROLL_BAR(priv->hscroll), hadjust);
|
||||
g_signal_connect (hadjust, "changed", G_CALLBACK (
|
||||
child_adjustment_changed_cb), priv->hscroll);
|
||||
child_adjustment_changed_cb (hadjust, priv->hscroll);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
child_vadjustment_notify_cb (GObject *gobject,
|
||||
GParamSpec *arg1,
|
||||
gpointer user_data)
|
||||
{
|
||||
NbtkAdjustment *vadjust;
|
||||
|
||||
ClutterActor *actor = CLUTTER_ACTOR (gobject);
|
||||
NbtkScrollViewPrivate *priv = NBTK_SCROLL_VIEW (user_data)->priv;
|
||||
|
||||
vadjust = nbtk_scroll_bar_get_adjustment (NBTK_SCROLL_BAR(priv->vscroll));
|
||||
if (vadjust)
|
||||
g_signal_handlers_disconnect_by_func (vadjust,
|
||||
child_adjustment_changed_cb,
|
||||
priv->vscroll);
|
||||
|
||||
nbtk_scrollable_get_adjustments (NBTK_SCROLLABLE(actor), NULL, &vadjust);
|
||||
if (vadjust)
|
||||
{
|
||||
/* Force scroll step if neede. */
|
||||
if (priv->row_size_set)
|
||||
{
|
||||
g_object_set (vadjust,
|
||||
"step-increment", priv->row_size,
|
||||
NULL);
|
||||
}
|
||||
|
||||
nbtk_scroll_bar_set_adjustment (NBTK_SCROLL_BAR(priv->vscroll), vadjust);
|
||||
g_signal_connect (vadjust, "changed", G_CALLBACK (
|
||||
child_adjustment_changed_cb), priv->vscroll);
|
||||
child_adjustment_changed_cb (vadjust, priv->vscroll);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_scroll_view_init (NbtkScrollView *self)
|
||||
{
|
||||
NbtkScrollViewPrivate *priv = self->priv = SCROLL_VIEW_PRIVATE (self);
|
||||
|
||||
priv->hscroll = CLUTTER_ACTOR (nbtk_scroll_bar_new (NULL));
|
||||
priv->vscroll = g_object_new (NBTK_TYPE_SCROLL_BAR, "vertical", TRUE, NULL);
|
||||
|
||||
clutter_actor_set_parent (priv->hscroll, CLUTTER_ACTOR (self));
|
||||
clutter_actor_set_parent (priv->vscroll, CLUTTER_ACTOR (self));
|
||||
|
||||
/* mouse scroll is enabled by default, so we also need to be reactive */
|
||||
priv->mouse_scroll = TRUE;
|
||||
g_object_set (G_OBJECT (self), "reactive", TRUE, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_scroll_view_add (ClutterContainer *container,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
NbtkScrollView *self = NBTK_SCROLL_VIEW (container);
|
||||
NbtkScrollViewPrivate *priv = self->priv;
|
||||
|
||||
if (NBTK_IS_SCROLLABLE (actor))
|
||||
{
|
||||
priv->child = actor;
|
||||
|
||||
/* chain up to NbtkBin::add() */
|
||||
nbtk_scroll_view_parent_iface->add (container, actor);
|
||||
|
||||
/* Get adjustments for scroll-bars */
|
||||
g_signal_connect (actor, "notify::hadjustment",
|
||||
G_CALLBACK (child_hadjustment_notify_cb),
|
||||
container);
|
||||
g_signal_connect (actor, "notify::vadjustment",
|
||||
G_CALLBACK (child_vadjustment_notify_cb),
|
||||
container);
|
||||
child_hadjustment_notify_cb (G_OBJECT (actor), NULL, container);
|
||||
child_vadjustment_notify_cb (G_OBJECT (actor), NULL, container);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("Attempting to add an actor of type %s to "
|
||||
"a NbtkScrollView, but the actor does "
|
||||
"not implement NbtkScrollable.",
|
||||
g_type_name (G_OBJECT_TYPE (actor)));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_scroll_view_remove (ClutterContainer *container,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
NbtkScrollViewPrivate *priv = NBTK_SCROLL_VIEW (container)->priv;
|
||||
|
||||
if (actor == priv->child)
|
||||
{
|
||||
g_object_ref (priv->child);
|
||||
|
||||
/* chain up to NbtkBin::remove() */
|
||||
nbtk_scroll_view_parent_iface->remove (container, actor);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (priv->child,
|
||||
child_hadjustment_notify_cb,
|
||||
container);
|
||||
g_signal_handlers_disconnect_by_func (priv->child,
|
||||
child_vadjustment_notify_cb,
|
||||
container);
|
||||
nbtk_scrollable_set_adjustments ((NbtkScrollable*) priv->child, NULL, NULL);
|
||||
|
||||
g_object_unref (priv->child);
|
||||
priv->child = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_scroll_view_foreach_with_internals (ClutterContainer *container,
|
||||
ClutterCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
NbtkScrollViewPrivate *priv = NBTK_SCROLL_VIEW (container)->priv;
|
||||
|
||||
if (priv->child != NULL)
|
||||
callback (priv->child, user_data);
|
||||
|
||||
if (priv->hscroll != NULL)
|
||||
callback (priv->hscroll, user_data);
|
||||
|
||||
if (priv->vscroll != NULL)
|
||||
callback (priv->vscroll, user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_container_iface_init (ClutterContainerIface *iface)
|
||||
{
|
||||
/* store a pointer to the NbtkBin implementation of
|
||||
* ClutterContainer so that we can chain up when
|
||||
* overriding the methods
|
||||
*/
|
||||
nbtk_scroll_view_parent_iface = g_type_interface_peek_parent (iface);
|
||||
|
||||
iface->add = nbtk_scroll_view_add;
|
||||
iface->remove = nbtk_scroll_view_remove;
|
||||
iface->foreach_with_internals = nbtk_scroll_view_foreach_with_internals;
|
||||
}
|
||||
|
||||
NbtkWidget *
|
||||
nbtk_scroll_view_new (void)
|
||||
{
|
||||
return g_object_new (NBTK_TYPE_SCROLL_VIEW, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* nbtk_scroll_view_get_hscroll_bar:
|
||||
* @scroll: a #NbtkScrollView
|
||||
*
|
||||
* Gets the horizontal scrollbar of the scrollbiew
|
||||
*
|
||||
* Return value: (transfer none): the horizontal #NbtkScrollbar
|
||||
*/
|
||||
ClutterActor *
|
||||
nbtk_scroll_view_get_hscroll_bar (NbtkScrollView *scroll)
|
||||
{
|
||||
g_return_val_if_fail (NBTK_IS_SCROLL_VIEW (scroll), NULL);
|
||||
|
||||
return scroll->priv->hscroll;
|
||||
}
|
||||
|
||||
/**
|
||||
* nbtk_scroll_view_get_vscroll_bar:
|
||||
* @scroll: a #NbtkScrollView
|
||||
*
|
||||
* Gets the vertical scrollbar of the scrollbiew
|
||||
*
|
||||
* Return value: (transfer none): the vertical #NbtkScrollbar
|
||||
*/
|
||||
ClutterActor *
|
||||
nbtk_scroll_view_get_vscroll_bar (NbtkScrollView *scroll)
|
||||
{
|
||||
g_return_val_if_fail (NBTK_IS_SCROLL_VIEW (scroll), NULL);
|
||||
|
||||
return scroll->priv->vscroll;
|
||||
}
|
||||
|
||||
gfloat
|
||||
nbtk_scroll_view_get_column_size (NbtkScrollView *scroll)
|
||||
{
|
||||
NbtkAdjustment *adjustment;
|
||||
gdouble column_size;
|
||||
|
||||
g_return_val_if_fail (scroll, 0);
|
||||
|
||||
adjustment = nbtk_scroll_bar_get_adjustment (
|
||||
NBTK_SCROLL_BAR (scroll->priv->hscroll));
|
||||
g_object_get (adjustment,
|
||||
"step-increment", &column_size,
|
||||
NULL);
|
||||
|
||||
return column_size;
|
||||
}
|
||||
|
||||
void
|
||||
nbtk_scroll_view_set_column_size (NbtkScrollView *scroll,
|
||||
gfloat column_size)
|
||||
{
|
||||
NbtkAdjustment *adjustment;
|
||||
|
||||
g_return_if_fail (scroll);
|
||||
|
||||
if (column_size < 0)
|
||||
{
|
||||
scroll->priv->column_size_set = FALSE;
|
||||
scroll->priv->column_size = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
scroll->priv->column_size_set = TRUE;
|
||||
scroll->priv->column_size = column_size;
|
||||
|
||||
adjustment = nbtk_scroll_bar_get_adjustment (
|
||||
NBTK_SCROLL_BAR (scroll->priv->hscroll));
|
||||
|
||||
if (adjustment)
|
||||
g_object_set (adjustment,
|
||||
"step-increment", (gdouble) scroll->priv->column_size,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
gfloat
|
||||
nbtk_scroll_view_get_row_size (NbtkScrollView *scroll)
|
||||
{
|
||||
NbtkAdjustment *adjustment;
|
||||
gdouble row_size;
|
||||
|
||||
g_return_val_if_fail (scroll, 0);
|
||||
|
||||
adjustment = nbtk_scroll_bar_get_adjustment (
|
||||
NBTK_SCROLL_BAR (scroll->priv->vscroll));
|
||||
g_object_get (adjustment,
|
||||
"step-increment", &row_size,
|
||||
NULL);
|
||||
|
||||
return row_size;
|
||||
}
|
||||
|
||||
void
|
||||
nbtk_scroll_view_set_row_size (NbtkScrollView *scroll,
|
||||
gfloat row_size)
|
||||
{
|
||||
NbtkAdjustment *adjustment;
|
||||
|
||||
g_return_if_fail (scroll);
|
||||
|
||||
if (row_size < 0)
|
||||
{
|
||||
scroll->priv->row_size_set = FALSE;
|
||||
scroll->priv->row_size = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
scroll->priv->row_size_set = TRUE;
|
||||
scroll->priv->row_size = row_size;
|
||||
|
||||
adjustment = nbtk_scroll_bar_get_adjustment (
|
||||
NBTK_SCROLL_BAR (scroll->priv->vscroll));
|
||||
|
||||
if (adjustment)
|
||||
g_object_set (adjustment,
|
||||
"step-increment", (gdouble) scroll->priv->row_size,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nbtk_scroll_view_set_mouse_scrolling (NbtkScrollView *scroll,
|
||||
gboolean enabled)
|
||||
{
|
||||
NbtkScrollViewPrivate *priv;
|
||||
|
||||
g_return_if_fail (NBTK_IS_SCROLL_VIEW (scroll));
|
||||
|
||||
priv = NBTK_SCROLL_VIEW (scroll)->priv;
|
||||
|
||||
if (priv->mouse_scroll != enabled)
|
||||
{
|
||||
priv->mouse_scroll = enabled;
|
||||
|
||||
/* make sure we can receive mouse wheel events */
|
||||
if (enabled)
|
||||
clutter_actor_set_reactive ((ClutterActor *) scroll, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
nbtk_scroll_view_get_mouse_scrolling (NbtkScrollView *scroll)
|
||||
{
|
||||
NbtkScrollViewPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (NBTK_IS_SCROLL_VIEW (scroll), FALSE);
|
||||
|
||||
priv = NBTK_SCROLL_VIEW (scroll)->priv;
|
||||
|
||||
return priv->mouse_scroll;
|
||||
}
|
87
src/nbtk/nbtk-scroll-view.h
Normal file
87
src/nbtk/nbtk-scroll-view.h
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* nbtk-scroll-view.h: Container with scroll-bars
|
||||
*
|
||||
* Copyright 2008 OpenedHand
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Written by: Chris Lord <chris@openedhand.com>
|
||||
* Port to Nbtk by: Robert Staudinger <robsta@openedhand.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(NBTK_H_INSIDE) && !defined(NBTK_COMPILATION)
|
||||
#error "Only <nbtk/nbtk.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef __NBTK_SCROLL_VIEW_H__
|
||||
#define __NBTK_SCROLL_VIEW_H__
|
||||
|
||||
#include <nbtk/nbtk-bin.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NBTK_TYPE_SCROLL_VIEW (nbtk_scroll_view_get_type())
|
||||
#define NBTK_SCROLL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NBTK_TYPE_SCROLL_VIEW, NbtkScrollView))
|
||||
#define NBTK_IS_SCROLL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NBTK_TYPE_SCROLL_VIEW))
|
||||
#define NBTK_SCROLL_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NBTK_TYPE_SCROLL_VIEW, NbtkScrollViewClass))
|
||||
#define NBTK_IS_SCROLL_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NBTK_TYPE_SCROLL_VIEW))
|
||||
#define NBTK_SCROLL_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NBTK_TYPE_SCROLL_VIEW, NbtkScrollViewClass))
|
||||
|
||||
typedef struct _NbtkScrollView NbtkScrollView;
|
||||
typedef struct _NbtkScrollViewPrivate NbtkScrollViewPrivate;
|
||||
typedef struct _NbtkScrollViewClass NbtkScrollViewClass;
|
||||
|
||||
/**
|
||||
* NbtkScrollView:
|
||||
*
|
||||
* The contents of this structure are private and should only be accessed
|
||||
* through the public API.
|
||||
*/
|
||||
struct _NbtkScrollView
|
||||
{
|
||||
/*< private >*/
|
||||
NbtkBin parent_instance;
|
||||
|
||||
NbtkScrollViewPrivate *priv;
|
||||
};
|
||||
|
||||
struct _NbtkScrollViewClass
|
||||
{
|
||||
NbtkBinClass parent_class;
|
||||
};
|
||||
|
||||
GType nbtk_scroll_view_get_type (void) G_GNUC_CONST;
|
||||
|
||||
NbtkWidget * nbtk_scroll_view_new (void);
|
||||
|
||||
ClutterActor * nbtk_scroll_view_get_hscroll_bar (NbtkScrollView *scroll);
|
||||
ClutterActor * nbtk_scroll_view_get_vscroll_bar (NbtkScrollView *scroll);
|
||||
|
||||
gfloat nbtk_scroll_view_get_column_size (NbtkScrollView *scroll);
|
||||
void nbtk_scroll_view_set_column_size (NbtkScrollView *scroll,
|
||||
gfloat column_size);
|
||||
|
||||
gfloat nbtk_scroll_view_get_row_size (NbtkScrollView *scroll);
|
||||
void nbtk_scroll_view_set_row_size (NbtkScrollView *scroll,
|
||||
gfloat row_size);
|
||||
|
||||
void nbtk_scroll_view_set_mouse_scrolling (NbtkScrollView *scroll, gboolean enabled);
|
||||
gboolean nbtk_scroll_view_get_mouse_scrolling (NbtkScrollView *scroll);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NBTK_SCROLL_VIEW_H__ */
|
96
src/nbtk/nbtk-scrollable.c
Normal file
96
src/nbtk/nbtk-scrollable.c
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* nbtk-scrollable.c: Scrollable interface
|
||||
*
|
||||
* Copyright 2008 OpenedHand
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Written by: Chris Lord <chris@openedhand.com>
|
||||
* Port to Nbtk by: Robert Staudinger <robsta@openedhand.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nbtk-scrollable.h"
|
||||
|
||||
static void
|
||||
nbtk_scrollable_base_init (gpointer g_iface)
|
||||
{
|
||||
static gboolean initialized = FALSE;
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
g_object_interface_install_property (g_iface,
|
||||
g_param_spec_object ("hadjustment",
|
||||
"NbtkAdjustment",
|
||||
"Horizontal adjustment",
|
||||
NBTK_TYPE_ADJUSTMENT,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_interface_install_property (g_iface,
|
||||
g_param_spec_object ("vadjustment",
|
||||
"NbtkAdjustment",
|
||||
"Vertical adjustment",
|
||||
NBTK_TYPE_ADJUSTMENT,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
initialized = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
GType
|
||||
nbtk_scrollable_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
if (type == 0)
|
||||
{
|
||||
static const GTypeInfo info =
|
||||
{
|
||||
sizeof (NbtkScrollableInterface),
|
||||
nbtk_scrollable_base_init, /* base_init */
|
||||
NULL,
|
||||
};
|
||||
type = g_type_register_static (G_TYPE_INTERFACE,
|
||||
"NbtkScrollable", &info, 0);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
void
|
||||
nbtk_scrollable_set_adjustments (NbtkScrollable *scrollable,
|
||||
NbtkAdjustment *hadjustment,
|
||||
NbtkAdjustment *vadjustment)
|
||||
{
|
||||
NBTK_SCROLLABLE_GET_INTERFACE (scrollable)->set_adjustments (scrollable,
|
||||
hadjustment,
|
||||
vadjustment);
|
||||
}
|
||||
|
||||
/**
|
||||
* nbtk_scroll_bar_get_adjustments:
|
||||
* @hadjustment: (transfer none) (out) (allow-none): location to store the horizontal adjustment, or %NULL
|
||||
* @vadjustment: (transfer none) (out) (allow-none): location to store the vertical adjustment, or %NULL
|
||||
*
|
||||
* Gets the adjustment objects that store the offsets of the scrollable widget
|
||||
* into its possible scrolling area.
|
||||
*/
|
||||
void
|
||||
nbtk_scrollable_get_adjustments (NbtkScrollable *scrollable,
|
||||
NbtkAdjustment **hadjustment,
|
||||
NbtkAdjustment **vadjustment)
|
||||
{
|
||||
NBTK_SCROLLABLE_GET_INTERFACE (scrollable)->get_adjustments (scrollable,
|
||||
hadjustment,
|
||||
vadjustment);
|
||||
}
|
69
src/nbtk/nbtk-scrollable.h
Normal file
69
src/nbtk/nbtk-scrollable.h
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* nbtk-scrollable.h: Scrollable interface
|
||||
*
|
||||
* Copyright 2008 OpenedHand
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Written by: Chris Lord <chris@openedhand.com>
|
||||
* Port to Nbtk by: Robert Staudinger <robsta@openedhand.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(NBTK_H_INSIDE) && !defined(NBTK_COMPILATION)
|
||||
#error "Only <nbtk/nbtk.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef __NBTK_SCROLLABLE_H__
|
||||
#define __NBTK_SCROLLABLE_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <nbtk/nbtk-adjustment.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NBTK_TYPE_SCROLLABLE (nbtk_scrollable_get_type ())
|
||||
#define NBTK_SCROLLABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NBTK_TYPE_SCROLLABLE, NbtkScrollable))
|
||||
#define NBTK_IS_SCROLLABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NBTK_TYPE_SCROLLABLE))
|
||||
#define NBTK_SCROLLABLE_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), NBTK_TYPE_SCROLLABLE, NbtkScrollableInterface))
|
||||
|
||||
typedef struct _NbtkScrollable NbtkScrollable; /* Dummy object */
|
||||
typedef struct _NbtkScrollableInterface NbtkScrollableInterface;
|
||||
|
||||
struct _NbtkScrollableInterface
|
||||
{
|
||||
GTypeInterface parent;
|
||||
|
||||
void (* set_adjustments) (NbtkScrollable *scrollable,
|
||||
NbtkAdjustment *hadjustment,
|
||||
NbtkAdjustment *vadjustment);
|
||||
void (* get_adjustments) (NbtkScrollable *scrollable,
|
||||
NbtkAdjustment **hadjustment,
|
||||
NbtkAdjustment **vadjustment);
|
||||
};
|
||||
|
||||
GType nbtk_scrollable_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void nbtk_scrollable_set_adjustments (NbtkScrollable *scrollable,
|
||||
NbtkAdjustment *hadjustment,
|
||||
NbtkAdjustment *vadjustment);
|
||||
void nbtk_scrollable_get_adjustments (NbtkScrollable *scrollable,
|
||||
NbtkAdjustment **hadjustment,
|
||||
NbtkAdjustment **vadjustment);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NBTK_SCROLLABLE_H__ */
|
@ -1,8 +1,7 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-subtexture.h: Class to wrap a texture and "subframe" it.
|
||||
* nbtk-subtexture.h: Class to wrap a texture and "subframe" it.
|
||||
* based on
|
||||
* st-texture-frame.c: Expandible texture actor
|
||||
* nbtk-texture-frame.c: Expandible texture actor
|
||||
*
|
||||
* Copyright 2007 OpenedHand
|
||||
* Copyright 2009 Intel Corporation.
|
||||
@ -30,7 +29,7 @@
|
||||
#include <cogl/cogl.h>
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
#include "st-subtexture.h"
|
||||
#include "nbtk-subtexture.h"
|
||||
|
||||
enum
|
||||
{
|
||||
@ -44,29 +43,29 @@ enum
|
||||
PROP_HEIGHT
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (StSubtexture, st_subtexture, CLUTTER_TYPE_ACTOR);
|
||||
G_DEFINE_TYPE (NbtkSubtexture, nbtk_subtexture, CLUTTER_TYPE_ACTOR);
|
||||
|
||||
#define ST_SUBTEXTURE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ST_TYPE_SUBTEXTURE, StSubtexturePrivate))
|
||||
#define NBTK_SUBTEXTURE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), NBTK_TYPE_SUBTEXTURE, NbtkSubtexturePrivate))
|
||||
|
||||
struct _StSubtexturePrivate
|
||||
struct _NbtkSubtexturePrivate
|
||||
{
|
||||
ClutterTexture *parent_texture;
|
||||
|
||||
int left;
|
||||
int top;
|
||||
int width;
|
||||
int height;
|
||||
int left;
|
||||
int top;
|
||||
int width;
|
||||
int height;
|
||||
|
||||
CoglHandle material;
|
||||
CoglHandle material;
|
||||
};
|
||||
|
||||
static void
|
||||
st_subtexture_get_preferred_width (ClutterActor *self,
|
||||
gfloat for_height,
|
||||
gfloat *min_width_p,
|
||||
gfloat *natural_width_p)
|
||||
nbtk_subtexture_get_preferred_width (ClutterActor *self,
|
||||
gfloat for_height,
|
||||
gfloat *min_width_p,
|
||||
gfloat *natural_width_p)
|
||||
{
|
||||
StSubtexturePrivate *priv = ST_SUBTEXTURE (self)->priv;
|
||||
NbtkSubtexturePrivate *priv = NBTK_SUBTEXTURE (self)->priv;
|
||||
|
||||
if (G_UNLIKELY (priv->parent_texture == NULL))
|
||||
{
|
||||
@ -78,20 +77,20 @@ st_subtexture_get_preferred_width (ClutterActor *self,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (min_width_p)
|
||||
*min_width_p = priv->width;
|
||||
if (natural_width_p)
|
||||
*natural_width_p = priv->width;
|
||||
if (min_width_p)
|
||||
*min_width_p = priv->width;
|
||||
if (natural_width_p)
|
||||
*natural_width_p = priv->width;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
st_subtexture_get_preferred_height (ClutterActor *self,
|
||||
gfloat for_width,
|
||||
gfloat *min_height_p,
|
||||
gfloat *natural_height_p)
|
||||
nbtk_subtexture_get_preferred_height (ClutterActor *self,
|
||||
gfloat for_width,
|
||||
gfloat *min_height_p,
|
||||
gfloat *natural_height_p)
|
||||
{
|
||||
StSubtexturePrivate *priv = ST_SUBTEXTURE (self)->priv;
|
||||
NbtkSubtexturePrivate *priv = NBTK_SUBTEXTURE (self)->priv;
|
||||
|
||||
if (G_UNLIKELY (priv->parent_texture == NULL))
|
||||
{
|
||||
@ -103,17 +102,17 @@ st_subtexture_get_preferred_height (ClutterActor *self,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (min_height_p)
|
||||
*min_height_p = priv->height;
|
||||
if (natural_height_p)
|
||||
*natural_height_p = priv->height;
|
||||
if (min_height_p)
|
||||
*min_height_p = priv->height;
|
||||
if (natural_height_p)
|
||||
*natural_height_p = priv->height;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
st_subtexture_realize (ClutterActor *self)
|
||||
nbtk_subtexture_realize (ClutterActor *self)
|
||||
{
|
||||
StSubtexturePrivate *priv = ST_SUBTEXTURE (self)->priv;
|
||||
NbtkSubtexturePrivate *priv = NBTK_SUBTEXTURE (self)->priv;
|
||||
|
||||
if (priv->material != COGL_INVALID_HANDLE)
|
||||
return;
|
||||
@ -124,9 +123,9 @@ st_subtexture_realize (ClutterActor *self)
|
||||
}
|
||||
|
||||
static void
|
||||
st_subtexture_unrealize (ClutterActor *self)
|
||||
nbtk_subtexture_unrealize (ClutterActor *self)
|
||||
{
|
||||
StSubtexturePrivate *priv = ST_SUBTEXTURE (self)->priv;
|
||||
NbtkSubtexturePrivate *priv = NBTK_SUBTEXTURE (self)->priv;
|
||||
|
||||
if (priv->material == COGL_INVALID_HANDLE)
|
||||
return;
|
||||
@ -138,9 +137,9 @@ st_subtexture_unrealize (ClutterActor *self)
|
||||
}
|
||||
|
||||
static void
|
||||
st_subtexture_paint (ClutterActor *self)
|
||||
nbtk_subtexture_paint (ClutterActor *self)
|
||||
{
|
||||
StSubtexturePrivate *priv = ST_SUBTEXTURE (self)->priv;
|
||||
NbtkSubtexturePrivate *priv = NBTK_SUBTEXTURE (self)->priv;
|
||||
CoglHandle cogl_texture = COGL_INVALID_HANDLE;
|
||||
ClutterActorBox box = { 0, 0, 0, 0 };
|
||||
gfloat tx1, ty1, tx2, ty2, tex_width, tex_height, width, height;
|
||||
@ -184,18 +183,18 @@ st_subtexture_paint (ClutterActor *self)
|
||||
cogl_material_set_layer (priv->material, 0, cogl_texture);
|
||||
cogl_set_source (priv->material);
|
||||
|
||||
cogl_rectangle_with_texture_coords (0,0, (float) width, (float) height,
|
||||
tx1, ty1, tx2, ty2);
|
||||
cogl_rectangle_with_texture_coords (0,0, (float)width, (float)height,
|
||||
tx1, ty1, tx2, ty2);
|
||||
}
|
||||
|
||||
static inline void
|
||||
st_subtexture_set_frame_internal (StSubtexture *frame,
|
||||
int left,
|
||||
int top,
|
||||
int width,
|
||||
int height)
|
||||
nbtk_subtexture_set_frame_internal (NbtkSubtexture *frame,
|
||||
int left,
|
||||
int top,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
StSubtexturePrivate *priv = frame->priv;
|
||||
NbtkSubtexturePrivate *priv = frame->priv;
|
||||
GObject *gobject = G_OBJECT (frame);
|
||||
gboolean changed = FALSE;
|
||||
|
||||
@ -236,51 +235,51 @@ st_subtexture_set_frame_internal (StSubtexture *frame,
|
||||
}
|
||||
|
||||
static void
|
||||
st_subtexture_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
nbtk_subtexture_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StSubtexture *frame = ST_SUBTEXTURE (gobject);
|
||||
StSubtexturePrivate *priv = frame->priv;
|
||||
NbtkSubtexture *frame = NBTK_SUBTEXTURE (gobject);
|
||||
NbtkSubtexturePrivate *priv = frame->priv;
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_PARENT_TEXTURE:
|
||||
st_subtexture_set_parent_texture (frame,
|
||||
g_value_get_object (value));
|
||||
nbtk_subtexture_set_parent_texture (frame,
|
||||
g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_TOP:
|
||||
st_subtexture_set_frame_internal (frame,
|
||||
priv->left,
|
||||
g_value_get_int (value),
|
||||
priv->width,
|
||||
priv->height);
|
||||
nbtk_subtexture_set_frame_internal (frame,
|
||||
priv->left,
|
||||
g_value_get_int (value),
|
||||
priv->width,
|
||||
priv->height);
|
||||
break;
|
||||
|
||||
case PROP_LEFT:
|
||||
st_subtexture_set_frame_internal (frame,
|
||||
g_value_get_int (value),
|
||||
priv->top,
|
||||
priv->width,
|
||||
priv->height);
|
||||
nbtk_subtexture_set_frame_internal (frame,
|
||||
g_value_get_int (value),
|
||||
priv->top,
|
||||
priv->width,
|
||||
priv->height);
|
||||
break;
|
||||
|
||||
case PROP_WIDTH:
|
||||
st_subtexture_set_frame_internal (frame,
|
||||
priv->left,
|
||||
priv->top,
|
||||
g_value_get_int (value),
|
||||
priv->height);
|
||||
nbtk_subtexture_set_frame_internal (frame,
|
||||
priv->left,
|
||||
priv->top,
|
||||
g_value_get_int (value),
|
||||
priv->height);
|
||||
break;
|
||||
|
||||
case PROP_HEIGHT:
|
||||
st_subtexture_set_frame_internal (frame,
|
||||
priv->left,
|
||||
priv->top,
|
||||
priv->width,
|
||||
g_value_get_int (value));
|
||||
nbtk_subtexture_set_frame_internal (frame,
|
||||
priv->left,
|
||||
priv->top,
|
||||
priv->width,
|
||||
g_value_get_int (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -290,12 +289,12 @@ st_subtexture_set_property (GObject *gobject,
|
||||
}
|
||||
|
||||
static void
|
||||
st_subtexture_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
nbtk_subtexture_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StSubtexturePrivate *priv = ST_SUBTEXTURE (gobject)->priv;
|
||||
NbtkSubtexturePrivate *priv = NBTK_SUBTEXTURE (gobject)->priv;
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
@ -326,9 +325,9 @@ st_subtexture_get_property (GObject *gobject,
|
||||
}
|
||||
|
||||
static void
|
||||
st_subtexture_dispose (GObject *gobject)
|
||||
nbtk_subtexture_dispose (GObject *gobject)
|
||||
{
|
||||
StSubtexturePrivate *priv = ST_SUBTEXTURE (gobject)->priv;
|
||||
NbtkSubtexturePrivate *priv = NBTK_SUBTEXTURE (gobject)->priv;
|
||||
|
||||
if (priv->parent_texture)
|
||||
{
|
||||
@ -342,29 +341,29 @@ st_subtexture_dispose (GObject *gobject)
|
||||
priv->material = COGL_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (st_subtexture_parent_class)->dispose (gobject);
|
||||
G_OBJECT_CLASS (nbtk_subtexture_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
st_subtexture_class_init (StSubtextureClass *klass)
|
||||
nbtk_subtexture_class_init (NbtkSubtextureClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
||||
GParamSpec *pspec;
|
||||
|
||||
g_type_class_add_private (gobject_class, sizeof (StSubtexturePrivate));
|
||||
g_type_class_add_private (gobject_class, sizeof (NbtkSubtexturePrivate));
|
||||
|
||||
actor_class->get_preferred_width =
|
||||
st_subtexture_get_preferred_width;
|
||||
nbtk_subtexture_get_preferred_width;
|
||||
actor_class->get_preferred_height =
|
||||
st_subtexture_get_preferred_height;
|
||||
actor_class->realize = st_subtexture_realize;
|
||||
actor_class->unrealize = st_subtexture_unrealize;
|
||||
actor_class->paint = st_subtexture_paint;
|
||||
nbtk_subtexture_get_preferred_height;
|
||||
actor_class->realize = nbtk_subtexture_realize;
|
||||
actor_class->unrealize = nbtk_subtexture_unrealize;
|
||||
actor_class->paint = nbtk_subtexture_paint;
|
||||
|
||||
gobject_class->set_property = st_subtexture_set_property;
|
||||
gobject_class->get_property = st_subtexture_get_property;
|
||||
gobject_class->dispose = st_subtexture_dispose;
|
||||
gobject_class->set_property = nbtk_subtexture_set_property;
|
||||
gobject_class->get_property = nbtk_subtexture_get_property;
|
||||
gobject_class->dispose = nbtk_subtexture_dispose;
|
||||
|
||||
pspec = g_param_spec_object ("parent-texture",
|
||||
"Parent Texture",
|
||||
@ -375,115 +374,115 @@ st_subtexture_class_init (StSubtextureClass *klass)
|
||||
g_object_class_install_property (gobject_class, PROP_PARENT_TEXTURE, pspec);
|
||||
|
||||
pspec = g_param_spec_int ("left",
|
||||
"Left",
|
||||
"Left offset",
|
||||
0, G_MAXINT,
|
||||
0,
|
||||
G_PARAM_READWRITE);
|
||||
"Left",
|
||||
"Left offset",
|
||||
0, G_MAXINT,
|
||||
0,
|
||||
G_PARAM_READWRITE);
|
||||
g_object_class_install_property (gobject_class, PROP_LEFT, pspec);
|
||||
|
||||
pspec = g_param_spec_int ("top",
|
||||
"Top",
|
||||
"Top offset",
|
||||
0, G_MAXINT,
|
||||
0,
|
||||
G_PARAM_READWRITE);
|
||||
"Top",
|
||||
"Top offset",
|
||||
0, G_MAXINT,
|
||||
0,
|
||||
G_PARAM_READWRITE);
|
||||
g_object_class_install_property (gobject_class, PROP_TOP, pspec);
|
||||
|
||||
pspec = g_param_spec_int ("width",
|
||||
"Width",
|
||||
"Width",
|
||||
0, G_MAXINT,
|
||||
0,
|
||||
G_PARAM_READWRITE);
|
||||
"Width",
|
||||
"Width",
|
||||
0, G_MAXINT,
|
||||
0,
|
||||
G_PARAM_READWRITE);
|
||||
g_object_class_install_property (gobject_class, PROP_WIDTH, pspec);
|
||||
|
||||
pspec = g_param_spec_int ("height",
|
||||
"Height",
|
||||
"Height",
|
||||
0, G_MAXINT,
|
||||
0,
|
||||
G_PARAM_READWRITE);
|
||||
"Height",
|
||||
"Height",
|
||||
0, G_MAXINT,
|
||||
0,
|
||||
G_PARAM_READWRITE);
|
||||
g_object_class_install_property (gobject_class, PROP_HEIGHT, pspec);
|
||||
}
|
||||
|
||||
static void
|
||||
st_subtexture_init (StSubtexture *self)
|
||||
nbtk_subtexture_init (NbtkSubtexture *self)
|
||||
{
|
||||
StSubtexturePrivate *priv;
|
||||
NbtkSubtexturePrivate *priv;
|
||||
|
||||
self->priv = priv = ST_SUBTEXTURE_GET_PRIVATE (self);
|
||||
self->priv = priv = NBTK_SUBTEXTURE_GET_PRIVATE (self);
|
||||
|
||||
priv->material = COGL_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* st_subtexture_new:
|
||||
* nbtk_subtexture_new:
|
||||
* @texture: a #ClutterTexture or %NULL
|
||||
* @left: left
|
||||
* @top: top
|
||||
* @width: width
|
||||
* @height: height
|
||||
*
|
||||
* A #StSubtexture is a specialized texture that efficiently clones
|
||||
* A #NbtkSubtexture is a specialized texture that efficiently clones
|
||||
* an area of the given @texture while keeping preserving portions of the
|
||||
* same texture.
|
||||
*
|
||||
* A #StSubtexture can be used to make a rectangular texture fit a
|
||||
* A #NbtkSubtexture can be used to make a rectangular texture fit a
|
||||
* given size without stretching its borders.
|
||||
*
|
||||
* Return value: the newly created #StSubtexture
|
||||
* Return value: the newly created #NbtkSubtexture
|
||||
*/
|
||||
ClutterActor*
|
||||
st_subtexture_new (ClutterTexture *texture,
|
||||
gint left,
|
||||
gint top,
|
||||
gint width,
|
||||
gint height)
|
||||
nbtk_subtexture_new (ClutterTexture *texture,
|
||||
gint left,
|
||||
gint top,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
g_return_val_if_fail (texture == NULL || CLUTTER_IS_TEXTURE (texture), NULL);
|
||||
|
||||
return g_object_new (ST_TYPE_SUBTEXTURE,
|
||||
"parent-texture", texture,
|
||||
"top", top,
|
||||
"left", left,
|
||||
"width", width,
|
||||
"height", height,
|
||||
NULL);
|
||||
return g_object_new (NBTK_TYPE_SUBTEXTURE,
|
||||
"parent-texture", texture,
|
||||
"top", top,
|
||||
"left", left,
|
||||
"width", width,
|
||||
"height", height,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_subtexture_get_parent_texture:
|
||||
* @frame: A #StSubtexture
|
||||
* nbtk_subtexture_get_parent_texture:
|
||||
* @frame: A #NbtkSubtexture
|
||||
*
|
||||
* Return the texture used by the #StSubtexture
|
||||
* Return the texture used by the #NbtkSubtexture
|
||||
*
|
||||
* Returns: (transfer none): a #ClutterTexture owned by the #StSubtexture
|
||||
* Returns: (transfer none): a #ClutterTexture owned by the #NbtkSubtexture
|
||||
*/
|
||||
ClutterTexture *
|
||||
st_subtexture_get_parent_texture (StSubtexture *frame)
|
||||
nbtk_subtexture_get_parent_texture (NbtkSubtexture *frame)
|
||||
{
|
||||
g_return_val_if_fail (ST_IS_SUBTEXTURE (frame), NULL);
|
||||
g_return_val_if_fail (NBTK_IS_SUBTEXTURE (frame), NULL);
|
||||
|
||||
return frame->priv->parent_texture;
|
||||
}
|
||||
|
||||
/**
|
||||
* st_subtexture_set_parent_texture:
|
||||
* @frame: A #StSubtexture
|
||||
* nbtk_subtexture_set_parent_texture:
|
||||
* @frame: A #NbtkSubtexture
|
||||
* @texture: A #ClutterTexture
|
||||
*
|
||||
* Set the #ClutterTexture used by this #StSubtexture
|
||||
* Set the #ClutterTexture used by this #NbtkSubtexture
|
||||
*
|
||||
*/
|
||||
void
|
||||
st_subtexture_set_parent_texture (StSubtexture *frame,
|
||||
ClutterTexture *texture)
|
||||
nbtk_subtexture_set_parent_texture (NbtkSubtexture *frame,
|
||||
ClutterTexture *texture)
|
||||
{
|
||||
StSubtexturePrivate *priv;
|
||||
NbtkSubtexturePrivate *priv;
|
||||
gboolean was_visible;
|
||||
|
||||
g_return_if_fail (ST_IS_SUBTEXTURE (frame));
|
||||
g_return_if_fail (NBTK_IS_SUBTEXTURE (frame));
|
||||
g_return_if_fail (texture == NULL || CLUTTER_IS_TEXTURE (texture));
|
||||
|
||||
priv = frame->priv;
|
||||
@ -516,8 +515,8 @@ st_subtexture_set_parent_texture (StSubtexture *frame,
|
||||
}
|
||||
|
||||
/**
|
||||
* st_subtexture_set_frame:
|
||||
* @frame: A #StSubtexture
|
||||
* nbtk_subtexture_set_frame:
|
||||
* @frame: A #NbtkSubtexture
|
||||
* @left: left
|
||||
* @top: top
|
||||
* @width: width
|
||||
@ -527,20 +526,20 @@ st_subtexture_set_parent_texture (StSubtexture *frame,
|
||||
*
|
||||
*/
|
||||
void
|
||||
st_subtexture_set_frame (StSubtexture *frame,
|
||||
gint left,
|
||||
gint top,
|
||||
gint width,
|
||||
gint height)
|
||||
nbtk_subtexture_set_frame (NbtkSubtexture *frame,
|
||||
gint left,
|
||||
gint top,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
g_return_if_fail (ST_IS_SUBTEXTURE (frame));
|
||||
g_return_if_fail (NBTK_IS_SUBTEXTURE (frame));
|
||||
|
||||
st_subtexture_set_frame_internal (frame, left, top, width, height);
|
||||
nbtk_subtexture_set_frame_internal (frame, left, top, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_subtexture_get_frame:
|
||||
* @frame: A #StSubtexture
|
||||
* nbtk_subtexture_get_frame:
|
||||
* @frame: A #NbtkSubtexture
|
||||
* @left: left
|
||||
* @top: top
|
||||
* @width: width
|
||||
@ -550,15 +549,15 @@ st_subtexture_set_frame (StSubtexture *frame,
|
||||
*
|
||||
*/
|
||||
void
|
||||
st_subtexture_get_frame (StSubtexture *frame,
|
||||
gint *left,
|
||||
gint *top,
|
||||
gint *width,
|
||||
gint *height)
|
||||
nbtk_subtexture_get_frame (NbtkSubtexture *frame,
|
||||
gint *left,
|
||||
gint *top,
|
||||
gint *width,
|
||||
gint *height)
|
||||
{
|
||||
StSubtexturePrivate *priv;
|
||||
NbtkSubtexturePrivate *priv;
|
||||
|
||||
g_return_if_fail (ST_IS_SUBTEXTURE (frame));
|
||||
g_return_if_fail (NBTK_IS_SUBTEXTURE (frame));
|
||||
|
||||
priv = frame->priv;
|
||||
|
92
src/nbtk/nbtk-subtexture.h
Normal file
92
src/nbtk/nbtk-subtexture.h
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* nbtk-subtexture.h: Class to wrap a texture and "subframe" it.
|
||||
*
|
||||
* Based on
|
||||
* nbtk-texture-frame.h: Expandible texture actor
|
||||
*
|
||||
* Copyright 2007, 2008 OpenedHand Ltd
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __NBTK_SUBTEXTURE_H__
|
||||
#define __NBTK_SUBTEXTURE_H__
|
||||
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NBTK_TYPE_SUBTEXTURE (nbtk_subtexture_get_type ())
|
||||
#define NBTK_SUBTEXTURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NBTK_TYPE_SUBTEXTURE, NbtkSubtexture))
|
||||
#define NBTK_SUBTEXTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NBTK_TYPE_SUBTEXTURE, NbtkSubtextureClass))
|
||||
#define NBTK_IS_SUBTEXTURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NBTK_TYPE_SUBTEXTURE))
|
||||
#define NBTK_IS_SUBTEXTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NBTK_TYPE_SUBTEXTURE))
|
||||
#define NBTK_SUBTEXTURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NBTK_TYPE_SUBTEXTURE, NbtkSubtextureClass))
|
||||
|
||||
typedef struct _NbtkSubtexture NbtkSubtexture;
|
||||
typedef struct _NbtkSubtexturePrivate NbtkSubtexturePrivate;
|
||||
typedef struct _NbtkSubtextureClass NbtkSubtextureClass;
|
||||
|
||||
/**
|
||||
* NbtkSubtexture:
|
||||
*
|
||||
* The contents of this structure are private and should only be accessed
|
||||
* through the public API.
|
||||
*/
|
||||
struct _NbtkSubtexture
|
||||
{
|
||||
/*< private >*/
|
||||
ClutterActor parent_instance;
|
||||
|
||||
NbtkSubtexturePrivate *priv;
|
||||
};
|
||||
|
||||
struct _NbtkSubtextureClass
|
||||
{
|
||||
ClutterActorClass parent_class;
|
||||
|
||||
/* padding for future expansion */
|
||||
void (*_nbtk_box_1) (void);
|
||||
void (*_nbtk_box_2) (void);
|
||||
void (*_nbtk_box_3) (void);
|
||||
void (*_nbtk_box_4) (void);
|
||||
};
|
||||
|
||||
GType nbtk_subtexture_get_type (void) G_GNUC_CONST;
|
||||
ClutterActor * nbtk_subtexture_new (ClutterTexture *texture,
|
||||
gint top,
|
||||
gint left,
|
||||
gint width,
|
||||
gint height);
|
||||
void nbtk_subtexture_set_parent_texture (NbtkSubtexture *frame,
|
||||
ClutterTexture *texture);
|
||||
ClutterTexture *nbtk_subtexture_get_parent_texture (NbtkSubtexture *frame);
|
||||
void nbtk_subtexture_set_frame (NbtkSubtexture *frame,
|
||||
gint top,
|
||||
gint left,
|
||||
gint width,
|
||||
gint height);
|
||||
void nbtk_subtexture_get_frame (NbtkSubtexture *frame,
|
||||
gint *top,
|
||||
gint *left,
|
||||
gint *width,
|
||||
gint *height);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NBTK_SUBTEXTURE_H__ */
|
456
src/nbtk/nbtk-texture-cache.c
Normal file
456
src/nbtk/nbtk-texture-cache.c
Normal file
@ -0,0 +1,456 @@
|
||||
/*
|
||||
* nbtk-widget.h: Base class for Nbtk actors
|
||||
*
|
||||
* Copyright 2007 OpenedHand
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:nbtk-texture-cache
|
||||
* @short_description: A per-process store to cache textures
|
||||
*
|
||||
* #NbtkTextureCache allows an application to re-use an previously loaded
|
||||
* textures.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "nbtk-texture-cache.h"
|
||||
#include "nbtk-marshal.h"
|
||||
#include "nbtk-private.h"
|
||||
#include "nbtk-subtexture.h"
|
||||
G_DEFINE_TYPE (NbtkTextureCache, nbtk_texture_cache, G_TYPE_OBJECT)
|
||||
|
||||
#define TEXTURE_CACHE_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), NBTK_TYPE_TEXTURE_CACHE, NbtkTextureCachePrivate))
|
||||
|
||||
typedef struct _NbtkTextureCachePrivate NbtkTextureCachePrivate;
|
||||
|
||||
struct _NbtkTextureCachePrivate
|
||||
{
|
||||
GHashTable *cache;
|
||||
};
|
||||
|
||||
typedef struct FinalizedClosure
|
||||
{
|
||||
gchar *path;
|
||||
NbtkTextureCache *cache;
|
||||
} FinalizedClosure;
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
};
|
||||
|
||||
static NbtkTextureCache* __cache_singleton = NULL;
|
||||
|
||||
/*
|
||||
* Convention: posX with a value of -1 indicates whole texture
|
||||
*/
|
||||
typedef struct NbtkTextureCacheItem {
|
||||
char filename[256];
|
||||
int width, height;
|
||||
int posX, posY;
|
||||
ClutterActor *ptr;
|
||||
} NbtkTextureCacheItem;
|
||||
|
||||
static NbtkTextureCacheItem *
|
||||
nbtk_texture_cache_item_new (void)
|
||||
{
|
||||
return g_slice_new0 (NbtkTextureCacheItem);
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_texture_cache_item_free (NbtkTextureCacheItem *item)
|
||||
{
|
||||
g_slice_free (NbtkTextureCacheItem, item);
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_texture_cache_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
switch (prop_id)
|
||||
{
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_texture_cache_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
switch (prop_id)
|
||||
{
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_texture_cache_dispose (GObject *object)
|
||||
{
|
||||
if (G_OBJECT_CLASS (nbtk_texture_cache_parent_class)->dispose)
|
||||
G_OBJECT_CLASS (nbtk_texture_cache_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_texture_cache_finalize (GObject *object)
|
||||
{
|
||||
NbtkTextureCachePrivate *priv = TEXTURE_CACHE_PRIVATE(object);
|
||||
|
||||
if (priv->cache)
|
||||
{
|
||||
g_hash_table_unref (priv->cache);
|
||||
priv->cache = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (nbtk_texture_cache_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_texture_cache_class_init (NbtkTextureCacheClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
g_type_class_add_private (klass, sizeof (NbtkTextureCachePrivate));
|
||||
|
||||
object_class->get_property = nbtk_texture_cache_get_property;
|
||||
object_class->set_property = nbtk_texture_cache_set_property;
|
||||
object_class->dispose = nbtk_texture_cache_dispose;
|
||||
object_class->finalize = nbtk_texture_cache_finalize;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
nbtk_texture_cache_init (NbtkTextureCache *self)
|
||||
{
|
||||
NbtkTextureCachePrivate *priv = TEXTURE_CACHE_PRIVATE(self);
|
||||
|
||||
priv->cache = g_hash_table_new_full (g_str_hash,
|
||||
g_str_equal,
|
||||
g_free,
|
||||
NULL);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* nbtk_texture_cache_get_default:
|
||||
*
|
||||
* Returns the default texture cache. This is owned by Nbtk and should not be
|
||||
* unreferenced or freed.
|
||||
*
|
||||
* Returns: (transfer none): a NbtkTextureCache
|
||||
*/
|
||||
NbtkTextureCache*
|
||||
nbtk_texture_cache_get_default (void)
|
||||
{
|
||||
if (G_UNLIKELY (__cache_singleton == NULL))
|
||||
__cache_singleton = g_object_new (NBTK_TYPE_TEXTURE_CACHE, NULL);
|
||||
|
||||
return __cache_singleton;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
on_texure_finalized (gpointer data,
|
||||
GObject *where_the_object_was)
|
||||
{
|
||||
FinalizedClosure *closure = (FinalizedClosure *)data;
|
||||
NbtkTextureCachePrivate *priv = TEXTURE_CACHE_PRIVATE(closure->cache);
|
||||
|
||||
g_hash_table_remove (priv->cache, closure->path);
|
||||
|
||||
g_free(closure->path);
|
||||
g_free(closure);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* nbtk_texture_cache_get_size:
|
||||
* @self: A #NbtkTextureCache
|
||||
*
|
||||
* Returns the number of items in the texture cache
|
||||
*
|
||||
* Returns: the current size of the cache
|
||||
*/
|
||||
gint
|
||||
nbtk_texture_cache_get_size (NbtkTextureCache *self)
|
||||
{
|
||||
NbtkTextureCachePrivate *priv = TEXTURE_CACHE_PRIVATE(self);
|
||||
|
||||
return g_hash_table_size (priv->cache);
|
||||
}
|
||||
|
||||
static void
|
||||
add_texture_to_cache (NbtkTextureCache *self,
|
||||
const gchar *path,
|
||||
NbtkTextureCacheItem *item)
|
||||
{
|
||||
/* FinalizedClosure *closure; */
|
||||
NbtkTextureCachePrivate *priv = TEXTURE_CACHE_PRIVATE(self);
|
||||
|
||||
g_hash_table_insert (priv->cache, g_strdup (path), item);
|
||||
|
||||
#if 0
|
||||
/* Make sure we can remove from hash */
|
||||
closure = g_new0 (FinalizedClosure, 1);
|
||||
closure->path = g_strdup (path);
|
||||
closure->cache = self;
|
||||
|
||||
g_object_weak_ref (G_OBJECT (res), on_texure_finalized, closure);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* NOTE: you should unref the returned texture when not needed */
|
||||
|
||||
/**
|
||||
* nbtk_texture_cache_get_texture:
|
||||
* @self: A #NbtkTextureCache
|
||||
* @path: A path to a image file
|
||||
* @want_clone: ignored
|
||||
*
|
||||
* Create a new ClutterTexture with the specified image. Adds the image to the
|
||||
* cache if the image had not been previously loaded. Subsequent calls with
|
||||
* the same image path will return a new ClutterTexture with the previously
|
||||
* loaded image.
|
||||
*
|
||||
* Returns: (transfer none): a newly created ClutterTexture
|
||||
*/
|
||||
ClutterTexture*
|
||||
nbtk_texture_cache_get_texture (NbtkTextureCache *self,
|
||||
const gchar *path,
|
||||
gboolean want_clone)
|
||||
{
|
||||
ClutterActor *texture;
|
||||
CoglHandle *handle;
|
||||
NbtkTextureCachePrivate *priv;
|
||||
NbtkTextureCacheItem *item;
|
||||
|
||||
g_return_val_if_fail (NBTK_IS_TEXTURE_CACHE (self), NULL);
|
||||
g_return_val_if_fail (path != NULL, NULL);
|
||||
|
||||
|
||||
priv = TEXTURE_CACHE_PRIVATE (self);
|
||||
|
||||
if (want_clone)
|
||||
g_warning ("The want_clone parameter of %s is now ignored. This function "
|
||||
"always returns a new ClutterTexture", __FUNCTION__);
|
||||
|
||||
item = g_hash_table_lookup (priv->cache, path);
|
||||
|
||||
if (item && item->posX != -1)
|
||||
{
|
||||
GError *err = NULL;
|
||||
/*
|
||||
* We have a cache hit, but it's for a partial texture. The only
|
||||
* sane option is to read it from disk and just don't cache it
|
||||
* at all.
|
||||
*/
|
||||
return CLUTTER_TEXTURE(clutter_texture_new_from_file(path, &err));
|
||||
}
|
||||
if (!item)
|
||||
{
|
||||
GError *err = NULL;
|
||||
|
||||
item = nbtk_texture_cache_item_new ();
|
||||
item->posX = -1;
|
||||
item->posY = -1;
|
||||
item->ptr = clutter_texture_new_from_file (path, &err);
|
||||
clutter_texture_get_base_size (CLUTTER_TEXTURE (item->ptr),
|
||||
&item->width, &item->height);
|
||||
|
||||
if (!item->ptr)
|
||||
{
|
||||
if (err)
|
||||
{
|
||||
g_warning ("Error loading image: %s", err->message);
|
||||
g_error_free (err);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
add_texture_to_cache (self, path, item);
|
||||
}
|
||||
|
||||
texture = clutter_texture_new ();
|
||||
handle = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (item->ptr));
|
||||
clutter_texture_set_cogl_texture ((ClutterTexture*) texture, handle);
|
||||
|
||||
return (ClutterTexture*) texture;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* nbtk_texture_cache_get_actor:
|
||||
* @self: A #NbtkTextureCache
|
||||
* @path: A path to a image file
|
||||
*
|
||||
* Create a new ClutterSubTexture with the specified image. Adds the image to the
|
||||
* cache if the image had not been previously loaded. Subsequent calls with
|
||||
* the same image path will return a new ClutterTexture with the previously
|
||||
* loaded image.
|
||||
*
|
||||
* Use this function if all you need is an actor for drawing.
|
||||
*
|
||||
* Returns: (transfer none): a newly created ClutterTexture
|
||||
*/
|
||||
ClutterActor*
|
||||
nbtk_texture_cache_get_actor (NbtkTextureCache *self,
|
||||
const gchar *path)
|
||||
{
|
||||
NbtkTextureCachePrivate *priv;
|
||||
NbtkTextureCacheItem *item;
|
||||
GError *err = NULL;
|
||||
|
||||
g_return_val_if_fail (NBTK_IS_TEXTURE_CACHE (self), NULL);
|
||||
g_return_val_if_fail (path != NULL, NULL);
|
||||
|
||||
priv = TEXTURE_CACHE_PRIVATE (self);
|
||||
|
||||
|
||||
item = g_hash_table_lookup (priv->cache, path);
|
||||
|
||||
if (item)
|
||||
{
|
||||
int posX = item->posX;
|
||||
int posY = item->posY;
|
||||
if (posX == -1)
|
||||
posX = 0;
|
||||
if (posY == -1)
|
||||
posY = 0;
|
||||
return nbtk_subtexture_new (CLUTTER_TEXTURE (item->ptr), posX, posY,
|
||||
item->width, item->height);
|
||||
}
|
||||
|
||||
item = nbtk_texture_cache_item_new ();
|
||||
item->posX = -1;
|
||||
item->posY = -1;
|
||||
item->ptr = clutter_texture_new_from_file (path, &err);
|
||||
clutter_texture_get_base_size (CLUTTER_TEXTURE (item->ptr),
|
||||
&item->width, &item->height);
|
||||
|
||||
if (!item->ptr)
|
||||
{
|
||||
if (err)
|
||||
{
|
||||
g_warning ("Error loading image: %s", err->message);
|
||||
g_error_free (err);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
add_texture_to_cache (self, path, item);
|
||||
|
||||
return nbtk_subtexture_new (CLUTTER_TEXTURE (item->ptr), 0, 0, item->width,
|
||||
item->height);
|
||||
}
|
||||
|
||||
void
|
||||
nbtk_texture_cache_load_cache (NbtkTextureCache *self,
|
||||
const gchar *filename)
|
||||
{
|
||||
FILE *file;
|
||||
NbtkTextureCacheItem *element, head;
|
||||
int ret;
|
||||
ClutterActor *actor;
|
||||
GError *error = NULL;
|
||||
NbtkTextureCachePrivate *priv;
|
||||
|
||||
g_return_if_fail (NBTK_IS_TEXTURE_CACHE (self));
|
||||
g_return_if_fail (filename != NULL);
|
||||
|
||||
priv = TEXTURE_CACHE_PRIVATE (self);
|
||||
|
||||
file = fopen(filename, "rm");
|
||||
if (!file)
|
||||
return;
|
||||
|
||||
ret = fread (&head, sizeof(NbtkTextureCacheItem), 1, file);
|
||||
if (ret < 0)
|
||||
{
|
||||
fclose (file);
|
||||
return;
|
||||
}
|
||||
|
||||
/* check if we already if this texture in the cache */
|
||||
if (g_hash_table_lookup (priv->cache, head.filename))
|
||||
{
|
||||
/* skip it, we're done */
|
||||
fclose (file);
|
||||
return;
|
||||
}
|
||||
|
||||
actor = clutter_texture_new_from_file (head.filename, &error);
|
||||
|
||||
if (error)
|
||||
{
|
||||
g_critical (G_STRLOC ": Error opening cache image file: %s",
|
||||
error->message);
|
||||
g_clear_error (&error);
|
||||
fclose (file);
|
||||
return;
|
||||
}
|
||||
|
||||
element = nbtk_texture_cache_item_new ();
|
||||
element->posX = -1;
|
||||
element->posY = -1;
|
||||
element->ptr = actor;
|
||||
strncpy (element->filename, head.filename, 256);
|
||||
clutter_texture_get_base_size (CLUTTER_TEXTURE (element->ptr),
|
||||
&element->width, &element->height);
|
||||
g_hash_table_insert (priv->cache, element->filename, element);
|
||||
|
||||
while (!feof (file))
|
||||
{
|
||||
element = nbtk_texture_cache_item_new ();
|
||||
ret = fread (element, sizeof (NbtkTextureCacheItem), 1, file);
|
||||
if (ret < 1)
|
||||
{
|
||||
/* end of file */
|
||||
nbtk_texture_cache_item_free (element);
|
||||
break;
|
||||
}
|
||||
|
||||
element->ptr = actor;
|
||||
|
||||
if (g_hash_table_lookup (priv->cache, element->filename))
|
||||
{
|
||||
/* file is already in the cache.... */
|
||||
nbtk_texture_cache_item_free (element);
|
||||
} else {
|
||||
g_hash_table_insert (priv->cache, element->filename, element);
|
||||
}
|
||||
}
|
||||
}
|
94
src/nbtk/nbtk-texture-cache.h
Normal file
94
src/nbtk/nbtk-texture-cache.h
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* nbtk-texture-cache.h: Cached textures object
|
||||
*
|
||||
* Copyright 2007 OpenedHand
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(NBTK_H_INSIDE) && !defined(NBTK_COMPILATION)
|
||||
#error "Only <nbtk/nbtk.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef _NBTK_TEXTURE_CACHE
|
||||
#define _NBTK_TEXTURE_CACHE
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NBTK_TYPE_TEXTURE_CACHE nbtk_texture_cache_get_type()
|
||||
|
||||
#define NBTK_TEXTURE_CACHE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
||||
NBTK_TYPE_TEXTURE_CACHE, NbtkTextureCache))
|
||||
|
||||
#define NBTK_TEXTURE_CACHE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), \
|
||||
NBTK_TYPE_TEXTURE_CACHE, NbtkTextureCacheClass))
|
||||
|
||||
#define NBTK_IS_TEXTURE_CACHE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
|
||||
NBTK_TYPE_TEXTURE_CACHE))
|
||||
|
||||
#define NBTK_IS_TEXTURE_CACHE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
|
||||
NBTK_TYPE_TEXTURE_CACHE))
|
||||
|
||||
#define NBTK_TEXTURE_CACHE_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
|
||||
NBTK_TYPE_TEXTURE_CACHE, NbtkTextureCacheClass))
|
||||
|
||||
/**
|
||||
* NbtkTextureCache:
|
||||
*
|
||||
* The contents of this structure are private and should only be accessed
|
||||
* through the public API.
|
||||
*/
|
||||
typedef struct {
|
||||
/*< private >*/
|
||||
GObject parent;
|
||||
} NbtkTextureCache;
|
||||
|
||||
typedef struct {
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (* loaded) (NbtkTextureCache *self,
|
||||
const gchar *path,
|
||||
ClutterTexture *texture);
|
||||
|
||||
void (* error_loading) (NbtkTextureCache *self,
|
||||
GError *error);
|
||||
} NbtkTextureCacheClass;
|
||||
|
||||
GType nbtk_texture_cache_get_type (void);
|
||||
|
||||
NbtkTextureCache* nbtk_texture_cache_get_default (void);
|
||||
ClutterTexture* nbtk_texture_cache_get_texture (NbtkTextureCache *self,
|
||||
const gchar *path,
|
||||
gboolean want_clone);
|
||||
ClutterActor* nbtk_texture_cache_get_actor (NbtkTextureCache *self,
|
||||
const gchar *path);
|
||||
|
||||
gint nbtk_texture_cache_get_size (NbtkTextureCache *self);
|
||||
|
||||
void nbtk_texture_cache_load_cache(NbtkTextureCache *self, const char *filename);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _NBTK_TEXTURE_CACHE */
|
@ -1,6 +1,5 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-texture-frame.h: Expandible texture actor
|
||||
* nbtk-texture-frame.h: Expandible texture actor
|
||||
*
|
||||
* Copyright 2007 OpenedHand
|
||||
* Copyright 2009 Intel Corporation.
|
||||
@ -22,10 +21,10 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:st-texture-frame
|
||||
* SECTION:nbtk-texture-frame
|
||||
* @short_description: Stretch a texture to fit the entire allocation
|
||||
*
|
||||
* #StTextureFrame
|
||||
* #NbtkTextureFrame
|
||||
*
|
||||
*/
|
||||
|
||||
@ -35,8 +34,8 @@
|
||||
|
||||
#include <cogl/cogl.h>
|
||||
|
||||
#include "st-texture-frame.h"
|
||||
#include "st-private.h"
|
||||
#include "nbtk-texture-frame.h"
|
||||
#include "nbtk-private.h"
|
||||
|
||||
enum
|
||||
{
|
||||
@ -50,27 +49,27 @@ enum
|
||||
PROP_LEFT
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (StTextureFrame, st_texture_frame, CLUTTER_TYPE_ACTOR);
|
||||
G_DEFINE_TYPE (NbtkTextureFrame, nbtk_texture_frame, CLUTTER_TYPE_ACTOR);
|
||||
|
||||
#define ST_TEXTURE_FRAME_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ST_TYPE_TEXTURE_FRAME, StTextureFramePrivate))
|
||||
#define NBTK_TEXTURE_FRAME_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), NBTK_TYPE_TEXTURE_FRAME, NbtkTextureFramePrivate))
|
||||
|
||||
struct _StTextureFramePrivate
|
||||
struct _NbtkTextureFramePrivate
|
||||
{
|
||||
ClutterTexture *parent_texture;
|
||||
|
||||
gfloat top;
|
||||
gfloat right;
|
||||
gfloat bottom;
|
||||
gfloat left;
|
||||
gfloat top;
|
||||
gfloat right;
|
||||
gfloat bottom;
|
||||
gfloat left;
|
||||
};
|
||||
|
||||
static void
|
||||
st_texture_frame_get_preferred_width (ClutterActor *self,
|
||||
gfloat for_height,
|
||||
gfloat *min_width_p,
|
||||
gfloat *natural_width_p)
|
||||
nbtk_texture_frame_get_preferred_width (ClutterActor *self,
|
||||
gfloat for_height,
|
||||
gfloat *min_width_p,
|
||||
gfloat *natural_width_p)
|
||||
{
|
||||
StTextureFramePrivate *priv = ST_TEXTURE_FRAME (self)->priv;
|
||||
NbtkTextureFramePrivate *priv = NBTK_TEXTURE_FRAME (self)->priv;
|
||||
|
||||
if (G_UNLIKELY (priv->parent_texture == NULL))
|
||||
{
|
||||
@ -98,12 +97,12 @@ st_texture_frame_get_preferred_width (ClutterActor *self,
|
||||
}
|
||||
|
||||
static void
|
||||
st_texture_frame_get_preferred_height (ClutterActor *self,
|
||||
gfloat for_width,
|
||||
gfloat *min_height_p,
|
||||
gfloat *natural_height_p)
|
||||
nbtk_texture_frame_get_preferred_height (ClutterActor *self,
|
||||
gfloat for_width,
|
||||
gfloat *min_height_p,
|
||||
gfloat *natural_height_p)
|
||||
{
|
||||
StTextureFramePrivate *priv = ST_TEXTURE_FRAME (self)->priv;
|
||||
NbtkTextureFramePrivate *priv = NBTK_TEXTURE_FRAME (self)->priv;
|
||||
|
||||
if (G_UNLIKELY (priv->parent_texture == NULL))
|
||||
{
|
||||
@ -131,9 +130,9 @@ st_texture_frame_get_preferred_height (ClutterActor *self,
|
||||
}
|
||||
|
||||
static void
|
||||
st_texture_frame_paint (ClutterActor *self)
|
||||
nbtk_texture_frame_paint (ClutterActor *self)
|
||||
{
|
||||
StTextureFramePrivate *priv = ST_TEXTURE_FRAME (self)->priv;
|
||||
NbtkTextureFramePrivate *priv = NBTK_TEXTURE_FRAME (self)->priv;
|
||||
CoglHandle cogl_texture = COGL_INVALID_HANDLE;
|
||||
CoglHandle cogl_material = COGL_INVALID_HANDLE;
|
||||
ClutterActorBox box = { 0, };
|
||||
@ -174,11 +173,11 @@ st_texture_frame_paint (ClutterActor *self)
|
||||
|
||||
ex = width - priv->right;
|
||||
if (ex < 0)
|
||||
ex = priv->right; /* FIXME ? */
|
||||
ex = priv->right; /* FIXME ? */
|
||||
|
||||
ey = height - priv->bottom;
|
||||
if (ey < 0)
|
||||
ey = priv->bottom; /* FIXME ? */
|
||||
ey = priv->bottom; /* FIXME ? */
|
||||
|
||||
opacity = clutter_actor_get_paint_opacity (self);
|
||||
|
||||
@ -191,65 +190,65 @@ st_texture_frame_paint (ClutterActor *self)
|
||||
|
||||
{
|
||||
GLfloat rectangles[] =
|
||||
{
|
||||
/* top left corner */
|
||||
0, 0, priv->left, priv->top,
|
||||
0.0, 0.0,
|
||||
tx1, ty1,
|
||||
{
|
||||
/* top left corner */
|
||||
0, 0, priv->left, priv->top,
|
||||
0.0, 0.0,
|
||||
tx1, ty1,
|
||||
|
||||
/* top middle */
|
||||
priv->left, 0, ex, priv->top,
|
||||
tx1, 0.0,
|
||||
tx2, ty1,
|
||||
/* top middle */
|
||||
priv->left, 0, ex, priv->top,
|
||||
tx1, 0.0,
|
||||
tx2, ty1,
|
||||
|
||||
/* top right */
|
||||
ex, 0, width, priv->top,
|
||||
tx2, 0.0,
|
||||
1.0, ty1,
|
||||
/* top right */
|
||||
ex, 0, width, priv->top,
|
||||
tx2, 0.0,
|
||||
1.0, ty1,
|
||||
|
||||
/* mid left */
|
||||
0, priv->top, priv->left, ey,
|
||||
0.0, ty1,
|
||||
tx1, ty2,
|
||||
/* mid left */
|
||||
0, priv->top, priv->left, ey,
|
||||
0.0, ty1,
|
||||
tx1, ty2,
|
||||
|
||||
/* center */
|
||||
priv->left, priv->top, ex, ey,
|
||||
tx1, ty1,
|
||||
tx2, ty2,
|
||||
/* center */
|
||||
priv->left, priv->top, ex, ey,
|
||||
tx1, ty1,
|
||||
tx2, ty2,
|
||||
|
||||
/* mid right */
|
||||
ex, priv->top, width, ey,
|
||||
tx2, ty1,
|
||||
1.0, ty2,
|
||||
/* mid right */
|
||||
ex, priv->top, width, ey,
|
||||
tx2, ty1,
|
||||
1.0, ty2,
|
||||
|
||||
/* bottom left */
|
||||
0, ey, priv->left, height,
|
||||
0.0, ty2,
|
||||
tx1, 1.0,
|
||||
/* bottom left */
|
||||
0, ey, priv->left, height,
|
||||
0.0, ty2,
|
||||
tx1, 1.0,
|
||||
|
||||
/* bottom center */
|
||||
priv->left, ey, ex, height,
|
||||
tx1, ty2,
|
||||
tx2, 1.0,
|
||||
/* bottom center */
|
||||
priv->left, ey, ex, height,
|
||||
tx1, ty2,
|
||||
tx2, 1.0,
|
||||
|
||||
/* bottom right */
|
||||
ex, ey, width, height,
|
||||
tx2, ty2,
|
||||
1.0, 1.0
|
||||
};
|
||||
/* bottom right */
|
||||
ex, ey, width, height,
|
||||
tx2, ty2,
|
||||
1.0, 1.0
|
||||
};
|
||||
|
||||
cogl_rectangles_with_texture_coords (rectangles, 9);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
st_texture_frame_set_frame_internal (StTextureFrame *frame,
|
||||
gfloat top,
|
||||
gfloat right,
|
||||
gfloat bottom,
|
||||
gfloat left)
|
||||
nbtk_texture_frame_set_frame_internal (NbtkTextureFrame *frame,
|
||||
gfloat top,
|
||||
gfloat right,
|
||||
gfloat bottom,
|
||||
gfloat left)
|
||||
{
|
||||
StTextureFramePrivate *priv = frame->priv;
|
||||
NbtkTextureFramePrivate *priv = frame->priv;
|
||||
GObject *gobject = G_OBJECT (frame);
|
||||
gboolean changed = FALSE;
|
||||
|
||||
@ -290,51 +289,51 @@ st_texture_frame_set_frame_internal (StTextureFrame *frame,
|
||||
}
|
||||
|
||||
static void
|
||||
st_texture_frame_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
nbtk_texture_frame_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StTextureFrame *frame = ST_TEXTURE_FRAME (gobject);
|
||||
StTextureFramePrivate *priv = frame->priv;
|
||||
NbtkTextureFrame *frame = NBTK_TEXTURE_FRAME (gobject);
|
||||
NbtkTextureFramePrivate *priv = frame->priv;
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_PARENT_TEXTURE:
|
||||
st_texture_frame_set_parent_texture (frame,
|
||||
g_value_get_object (value));
|
||||
nbtk_texture_frame_set_parent_texture (frame,
|
||||
g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_TOP:
|
||||
st_texture_frame_set_frame_internal (frame,
|
||||
g_value_get_float (value),
|
||||
priv->right,
|
||||
priv->bottom,
|
||||
priv->left);
|
||||
nbtk_texture_frame_set_frame_internal (frame,
|
||||
g_value_get_float (value),
|
||||
priv->right,
|
||||
priv->bottom,
|
||||
priv->left);
|
||||
break;
|
||||
|
||||
case PROP_RIGHT:
|
||||
st_texture_frame_set_frame_internal (frame,
|
||||
priv->top,
|
||||
g_value_get_float (value),
|
||||
priv->bottom,
|
||||
priv->left);
|
||||
nbtk_texture_frame_set_frame_internal (frame,
|
||||
priv->top,
|
||||
g_value_get_float (value),
|
||||
priv->bottom,
|
||||
priv->left);
|
||||
break;
|
||||
|
||||
case PROP_BOTTOM:
|
||||
st_texture_frame_set_frame_internal (frame,
|
||||
priv->top,
|
||||
priv->right,
|
||||
g_value_get_float (value),
|
||||
priv->left);
|
||||
nbtk_texture_frame_set_frame_internal (frame,
|
||||
priv->top,
|
||||
priv->right,
|
||||
g_value_get_float (value),
|
||||
priv->left);
|
||||
break;
|
||||
|
||||
case PROP_LEFT:
|
||||
st_texture_frame_set_frame_internal (frame,
|
||||
priv->top,
|
||||
priv->right,
|
||||
priv->bottom,
|
||||
g_value_get_float (value));
|
||||
nbtk_texture_frame_set_frame_internal (frame,
|
||||
priv->top,
|
||||
priv->right,
|
||||
priv->bottom,
|
||||
g_value_get_float (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -344,12 +343,12 @@ st_texture_frame_set_property (GObject *gobject,
|
||||
}
|
||||
|
||||
static void
|
||||
st_texture_frame_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
nbtk_texture_frame_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StTextureFramePrivate *priv = ST_TEXTURE_FRAME (gobject)->priv;
|
||||
NbtkTextureFramePrivate *priv = NBTK_TEXTURE_FRAME (gobject)->priv;
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
@ -380,9 +379,9 @@ st_texture_frame_get_property (GObject *gobject,
|
||||
}
|
||||
|
||||
static void
|
||||
st_texture_frame_dispose (GObject *gobject)
|
||||
nbtk_texture_frame_dispose (GObject *gobject)
|
||||
{
|
||||
StTextureFramePrivate *priv = ST_TEXTURE_FRAME (gobject)->priv;
|
||||
NbtkTextureFramePrivate *priv = NBTK_TEXTURE_FRAME (gobject)->priv;
|
||||
|
||||
if (priv->parent_texture)
|
||||
{
|
||||
@ -390,42 +389,42 @@ st_texture_frame_dispose (GObject *gobject)
|
||||
priv->parent_texture = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (st_texture_frame_parent_class)->dispose (gobject);
|
||||
G_OBJECT_CLASS (nbtk_texture_frame_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
st_texture_frame_class_init (StTextureFrameClass *klass)
|
||||
nbtk_texture_frame_class_init (NbtkTextureFrameClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
||||
GParamSpec *pspec;
|
||||
|
||||
g_type_class_add_private (gobject_class, sizeof (StTextureFramePrivate));
|
||||
g_type_class_add_private (gobject_class, sizeof (NbtkTextureFramePrivate));
|
||||
|
||||
actor_class->get_preferred_width =
|
||||
st_texture_frame_get_preferred_width;
|
||||
nbtk_texture_frame_get_preferred_width;
|
||||
actor_class->get_preferred_height =
|
||||
st_texture_frame_get_preferred_height;
|
||||
actor_class->paint = st_texture_frame_paint;
|
||||
nbtk_texture_frame_get_preferred_height;
|
||||
actor_class->paint = nbtk_texture_frame_paint;
|
||||
|
||||
gobject_class->set_property = st_texture_frame_set_property;
|
||||
gobject_class->get_property = st_texture_frame_get_property;
|
||||
gobject_class->dispose = st_texture_frame_dispose;
|
||||
gobject_class->set_property = nbtk_texture_frame_set_property;
|
||||
gobject_class->get_property = nbtk_texture_frame_get_property;
|
||||
gobject_class->dispose = nbtk_texture_frame_dispose;
|
||||
|
||||
pspec = g_param_spec_object ("parent-texture",
|
||||
"Parent Texture",
|
||||
"The parent ClutterTexture",
|
||||
CLUTTER_TYPE_TEXTURE,
|
||||
ST_PARAM_READWRITE |
|
||||
NBTK_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT);
|
||||
g_object_class_install_property (gobject_class, PROP_PARENT_TEXTURE, pspec);
|
||||
|
||||
pspec = g_param_spec_float ("left",
|
||||
"Left",
|
||||
"Left offset",
|
||||
0, G_MAXFLOAT,
|
||||
0, G_MAXFLOAT,
|
||||
0,
|
||||
ST_PARAM_READWRITE);
|
||||
NBTK_PARAM_READWRITE);
|
||||
g_object_class_install_property (gobject_class, PROP_LEFT, pspec);
|
||||
|
||||
pspec = g_param_spec_float ("top",
|
||||
@ -433,7 +432,7 @@ st_texture_frame_class_init (StTextureFrameClass *klass)
|
||||
"Top offset",
|
||||
0, G_MAXFLOAT,
|
||||
0,
|
||||
ST_PARAM_READWRITE);
|
||||
NBTK_PARAM_READWRITE);
|
||||
g_object_class_install_property (gobject_class, PROP_TOP, pspec);
|
||||
|
||||
pspec = g_param_spec_float ("bottom",
|
||||
@ -441,7 +440,7 @@ st_texture_frame_class_init (StTextureFrameClass *klass)
|
||||
"Bottom offset",
|
||||
0, G_MAXFLOAT,
|
||||
0,
|
||||
ST_PARAM_READWRITE);
|
||||
NBTK_PARAM_READWRITE);
|
||||
g_object_class_install_property (gobject_class, PROP_BOTTOM, pspec);
|
||||
|
||||
pspec = g_param_spec_float ("right",
|
||||
@ -449,85 +448,85 @@ st_texture_frame_class_init (StTextureFrameClass *klass)
|
||||
"Right offset",
|
||||
0, G_MAXFLOAT,
|
||||
0,
|
||||
ST_PARAM_READWRITE);
|
||||
NBTK_PARAM_READWRITE);
|
||||
g_object_class_install_property (gobject_class, PROP_RIGHT, pspec);
|
||||
}
|
||||
|
||||
static void
|
||||
st_texture_frame_init (StTextureFrame *self)
|
||||
nbtk_texture_frame_init (NbtkTextureFrame *self)
|
||||
{
|
||||
StTextureFramePrivate *priv;
|
||||
NbtkTextureFramePrivate *priv;
|
||||
|
||||
self->priv = priv = ST_TEXTURE_FRAME_GET_PRIVATE (self);
|
||||
self->priv = priv = NBTK_TEXTURE_FRAME_GET_PRIVATE (self);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_texture_frame_new:
|
||||
* nbtk_texture_frame_new:
|
||||
* @texture: a #ClutterTexture or %NULL
|
||||
* @left: left margin preserving its content
|
||||
* @top: top margin preserving its content
|
||||
* @right: right margin preserving its content
|
||||
* @bottom: bottom margin preserving its content
|
||||
*
|
||||
* A #StTextureFrame is a specialized texture that efficiently clones
|
||||
* A #NbtkTextureFrame is a specialized texture that efficiently clones
|
||||
* an area of the given @texture while keeping preserving portions of the
|
||||
* same texture.
|
||||
*
|
||||
* A #StTextureFrame can be used to make a rectangular texture fit a
|
||||
* A #NbtkTextureFrame can be used to make a rectangular texture fit a
|
||||
* given size without stretching its borders.
|
||||
*
|
||||
* Return value: the newly created #StTextureFrame
|
||||
* Return value: the newly created #NbtkTextureFrame
|
||||
*/
|
||||
ClutterActor*
|
||||
st_texture_frame_new (ClutterTexture *texture,
|
||||
gfloat top,
|
||||
gfloat right,
|
||||
gfloat bottom,
|
||||
gfloat left)
|
||||
nbtk_texture_frame_new (ClutterTexture *texture,
|
||||
gfloat top,
|
||||
gfloat right,
|
||||
gfloat bottom,
|
||||
gfloat left)
|
||||
{
|
||||
g_return_val_if_fail (texture == NULL || CLUTTER_IS_TEXTURE (texture), NULL);
|
||||
|
||||
return g_object_new (ST_TYPE_TEXTURE_FRAME,
|
||||
"parent-texture", texture,
|
||||
"top", top,
|
||||
"right", right,
|
||||
"bottom", bottom,
|
||||
"left", left,
|
||||
NULL);
|
||||
return g_object_new (NBTK_TYPE_TEXTURE_FRAME,
|
||||
"parent-texture", texture,
|
||||
"top", top,
|
||||
"right", right,
|
||||
"bottom", bottom,
|
||||
"left", left,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_texture_frame_get_parent_texture:
|
||||
* @frame: A #StTextureFrame
|
||||
* nbtk_texture_frame_get_parent_texture:
|
||||
* @frame: A #NbtkTextureFrame
|
||||
*
|
||||
* Return the texture used by the #StTextureFrame
|
||||
* Return the texture used by the #NbtkTextureFrame
|
||||
*
|
||||
* Returns: (transfer none): a #ClutterTexture owned by the #StTextureFrame
|
||||
* Returns: (transfer none): a #ClutterTexture owned by the #NbtkTextureFrame
|
||||
*/
|
||||
ClutterTexture *
|
||||
st_texture_frame_get_parent_texture (StTextureFrame *frame)
|
||||
nbtk_texture_frame_get_parent_texture (NbtkTextureFrame *frame)
|
||||
{
|
||||
g_return_val_if_fail (ST_IS_TEXTURE_FRAME (frame), NULL);
|
||||
g_return_val_if_fail (NBTK_IS_TEXTURE_FRAME (frame), NULL);
|
||||
|
||||
return frame->priv->parent_texture;
|
||||
}
|
||||
|
||||
/**
|
||||
* st_texture_frame_set_parent_texture:
|
||||
* @frame: A #StTextureFrame
|
||||
* nbtk_texture_frame_set_parent_texture:
|
||||
* @frame: A #NbtkTextureFrame
|
||||
* @texture: A #ClutterTexture
|
||||
*
|
||||
* Set the #ClutterTexture used by this #StTextureFrame
|
||||
* Set the #ClutterTexture used by this #NbtkTextureFrame
|
||||
*
|
||||
*/
|
||||
void
|
||||
st_texture_frame_set_parent_texture (StTextureFrame *frame,
|
||||
ClutterTexture *texture)
|
||||
nbtk_texture_frame_set_parent_texture (NbtkTextureFrame *frame,
|
||||
ClutterTexture *texture)
|
||||
{
|
||||
StTextureFramePrivate *priv;
|
||||
NbtkTextureFramePrivate *priv;
|
||||
gboolean was_visible;
|
||||
|
||||
g_return_if_fail (ST_IS_TEXTURE_FRAME (frame));
|
||||
g_return_if_fail (NBTK_IS_TEXTURE_FRAME (frame));
|
||||
g_return_if_fail (texture == NULL || CLUTTER_IS_TEXTURE (texture));
|
||||
|
||||
priv = frame->priv;
|
||||
@ -560,8 +559,8 @@ st_texture_frame_set_parent_texture (StTextureFrame *frame,
|
||||
}
|
||||
|
||||
/**
|
||||
* st_texture_frame_set_frame:
|
||||
* @frame: A #StTextureFrame
|
||||
* nbtk_texture_frame_set_frame:
|
||||
* @frame: A #NbtkTextureFrame
|
||||
* @top: width of the top slice
|
||||
* @right: width of the right slice
|
||||
* @bottom: width of the bottom slice
|
||||
@ -572,20 +571,20 @@ st_texture_frame_set_parent_texture (StTextureFrame *frame,
|
||||
*
|
||||
*/
|
||||
void
|
||||
st_texture_frame_set_frame (StTextureFrame *frame,
|
||||
gfloat top,
|
||||
gfloat right,
|
||||
gfloat bottom,
|
||||
gfloat left)
|
||||
nbtk_texture_frame_set_frame (NbtkTextureFrame *frame,
|
||||
gfloat top,
|
||||
gfloat right,
|
||||
gfloat bottom,
|
||||
gfloat left)
|
||||
{
|
||||
g_return_if_fail (ST_IS_TEXTURE_FRAME (frame));
|
||||
g_return_if_fail (NBTK_IS_TEXTURE_FRAME (frame));
|
||||
|
||||
st_texture_frame_set_frame_internal (frame, top, right, bottom, left);
|
||||
nbtk_texture_frame_set_frame_internal (frame, top, right, bottom, left);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_texture_frame_get_frame:
|
||||
* @frame: A #StTextureFrame
|
||||
* nbtk_texture_frame_get_frame:
|
||||
* @frame: A #NbtkTextureFrame
|
||||
* @top: width of the top slice
|
||||
* @right: width of the right slice
|
||||
* @bottom: width of the bottom slice
|
||||
@ -595,15 +594,15 @@ st_texture_frame_set_frame (StTextureFrame *frame,
|
||||
*
|
||||
*/
|
||||
void
|
||||
st_texture_frame_get_frame (StTextureFrame *frame,
|
||||
gfloat *top,
|
||||
gfloat *right,
|
||||
gfloat *bottom,
|
||||
gfloat *left)
|
||||
nbtk_texture_frame_get_frame (NbtkTextureFrame *frame,
|
||||
gfloat *top,
|
||||
gfloat *right,
|
||||
gfloat *bottom,
|
||||
gfloat *left)
|
||||
{
|
||||
StTextureFramePrivate *priv;
|
||||
NbtkTextureFramePrivate *priv;
|
||||
|
||||
g_return_if_fail (ST_IS_TEXTURE_FRAME (frame));
|
||||
g_return_if_fail (NBTK_IS_TEXTURE_FRAME (frame));
|
||||
|
||||
priv = frame->priv;
|
||||
|
92
src/nbtk/nbtk-texture-frame.h
Normal file
92
src/nbtk/nbtk-texture-frame.h
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* nbtk-texture-frame.h: Expandible texture actor
|
||||
*
|
||||
* Copyright 2007, 2008 OpenedHand Ltd
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(NBTK_H_INSIDE) && !defined(NBTK_COMPILATION)
|
||||
#error "Only <nbtk/nbtk.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef __NBTK_TEXTURE_FRAME_H__
|
||||
#define __NBTK_TEXTURE_FRAME_H__
|
||||
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NBTK_TYPE_TEXTURE_FRAME (nbtk_texture_frame_get_type ())
|
||||
#define NBTK_TEXTURE_FRAME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NBTK_TYPE_TEXTURE_FRAME, NbtkTextureFrame))
|
||||
#define NBTK_TEXTURE_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NBTK_TYPE_TEXTURE_FRAME, NbtkTextureFrameClass))
|
||||
#define NBTK_IS_TEXTURE_FRAME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NBTK_TYPE_TEXTURE_FRAME))
|
||||
#define NBTK_IS_TEXTURE_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NBTK_TYPE_TEXTURE_FRAME))
|
||||
#define NBTK_TEXTURE_FRAME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NBTK_TYPE_TEXTURE_FRAME, NbtkTextureFrameClass))
|
||||
|
||||
typedef struct _NbtkTextureFrame NbtkTextureFrame;
|
||||
typedef struct _NbtkTextureFramePrivate NbtkTextureFramePrivate;
|
||||
typedef struct _NbtkTextureFrameClass NbtkTextureFrameClass;
|
||||
|
||||
/**
|
||||
* NbtkTextureFrame:
|
||||
*
|
||||
* The contents of this structure are private and should only be accessed
|
||||
* through the public API.
|
||||
*/
|
||||
struct _NbtkTextureFrame
|
||||
{
|
||||
/*< private >*/
|
||||
ClutterActor parent_instance;
|
||||
|
||||
NbtkTextureFramePrivate *priv;
|
||||
};
|
||||
|
||||
struct _NbtkTextureFrameClass
|
||||
{
|
||||
ClutterActorClass parent_class;
|
||||
|
||||
/* padding for future expansion */
|
||||
void (*_clutter_box_1) (void);
|
||||
void (*_clutter_box_2) (void);
|
||||
void (*_clutter_box_3) (void);
|
||||
void (*_clutter_box_4) (void);
|
||||
};
|
||||
|
||||
GType nbtk_texture_frame_get_type (void) G_GNUC_CONST;
|
||||
ClutterActor * nbtk_texture_frame_new (ClutterTexture *texture,
|
||||
gfloat top,
|
||||
gfloat right,
|
||||
gfloat bottom,
|
||||
gfloat left);
|
||||
void nbtk_texture_frame_set_parent_texture (NbtkTextureFrame *frame,
|
||||
ClutterTexture *texture);
|
||||
ClutterTexture *nbtk_texture_frame_get_parent_texture (NbtkTextureFrame *frame);
|
||||
void nbtk_texture_frame_set_frame (NbtkTextureFrame *frame,
|
||||
gfloat top,
|
||||
gfloat right,
|
||||
gfloat bottom,
|
||||
gfloat left);
|
||||
void nbtk_texture_frame_get_frame (NbtkTextureFrame *frame,
|
||||
gfloat *top,
|
||||
gfloat *right,
|
||||
gfloat *bottom,
|
||||
gfloat *left);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NBTK_TEXTURE_FRAME_H__ */
|
@ -1,6 +1,5 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-tooltip.c: Plain tooltip actor
|
||||
* nbtk-tooltip.c: Plain tooltip actor
|
||||
*
|
||||
* Copyright 2008, 2009 Intel Corporation
|
||||
*
|
||||
@ -23,12 +22,12 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:st-tooltip
|
||||
* SECTION:nbtk-tooltip
|
||||
* @short_description: A tooltip widget
|
||||
*
|
||||
* #StTooltip implements a single tooltip. It should not normally be created
|
||||
* #NbtkTooltip implements a single tooltip. It should not normally be created
|
||||
* by the application but by the widget implementing tooltip capabilities, for
|
||||
* example, #st_button_set_tooltip().
|
||||
* example, #nbtk_button_set_tooltip().
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -42,10 +41,10 @@
|
||||
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
#include "st-tooltip.h"
|
||||
#include "nbtk-tooltip.h"
|
||||
|
||||
#include "st-widget.h"
|
||||
#include "st-private.h"
|
||||
#include "nbtk-widget.h"
|
||||
#include "nbtk-private.h"
|
||||
|
||||
enum
|
||||
{
|
||||
@ -55,37 +54,37 @@ enum
|
||||
PROP_TIP_AREA
|
||||
};
|
||||
|
||||
#define ST_TOOLTIP_GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), ST_TYPE_TOOLTIP, StTooltipPrivate))
|
||||
#define NBTK_TOOLTIP_GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), NBTK_TYPE_TOOLTIP, NbtkTooltipPrivate))
|
||||
|
||||
struct _StTooltipPrivate
|
||||
struct _NbtkTooltipPrivate
|
||||
{
|
||||
ClutterActor *label;
|
||||
ClutterActor *label;
|
||||
|
||||
gfloat arrow_offset;
|
||||
gboolean actor_below;
|
||||
gfloat arrow_offset;
|
||||
gboolean actor_below;
|
||||
|
||||
ClutterGeometry *tip_area;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (StTooltip, st_tooltip, ST_TYPE_WIDGET);
|
||||
G_DEFINE_TYPE (NbtkTooltip, nbtk_tooltip, NBTK_TYPE_WIDGET);
|
||||
|
||||
static void
|
||||
st_tooltip_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
nbtk_tooltip_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StTooltip *tooltip = ST_TOOLTIP (gobject);
|
||||
NbtkTooltip *tooltip = NBTK_TOOLTIP (gobject);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_LABEL:
|
||||
st_tooltip_set_label (tooltip, g_value_get_string (value));
|
||||
nbtk_tooltip_set_label (tooltip, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
case PROP_TIP_AREA:
|
||||
st_tooltip_set_tip_area (tooltip, g_value_get_boxed (value));
|
||||
nbtk_tooltip_set_tip_area (tooltip, g_value_get_boxed (value));
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
@ -94,12 +93,12 @@ st_tooltip_set_property (GObject *gobject,
|
||||
}
|
||||
|
||||
static void
|
||||
st_tooltip_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
nbtk_tooltip_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StTooltipPrivate *priv = ST_TOOLTIP (gobject)->priv;
|
||||
NbtkTooltipPrivate *priv = NBTK_TOOLTIP (gobject)->priv;
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
@ -118,43 +117,43 @@ st_tooltip_get_property (GObject *gobject,
|
||||
}
|
||||
|
||||
static void
|
||||
st_tooltip_style_changed (StWidget *self)
|
||||
nbtk_tooltip_style_changed (NbtkWidget *self)
|
||||
{
|
||||
StTooltipPrivate *priv;
|
||||
StThemeNode *theme_node;
|
||||
NbtkTooltipPrivate *priv;
|
||||
ShellThemeNode *theme_node;
|
||||
ClutterColor color;
|
||||
const PangoFontDescription *font;
|
||||
gchar *font_string;
|
||||
|
||||
priv = ST_TOOLTIP (self)->priv;
|
||||
theme_node = st_widget_get_theme_node (self);
|
||||
priv = NBTK_TOOLTIP (self)->priv;
|
||||
theme_node = nbtk_widget_get_theme_node (self);
|
||||
|
||||
st_theme_node_get_foreground_color (theme_node, &color);
|
||||
shell_theme_node_get_foreground_color (theme_node, &color);
|
||||
clutter_text_set_color (CLUTTER_TEXT (priv->label), &color);
|
||||
|
||||
font = st_theme_node_get_font (theme_node);
|
||||
font = shell_theme_node_get_font (theme_node);
|
||||
font_string = pango_font_description_to_string (font);
|
||||
clutter_text_set_font_name (CLUTTER_TEXT (priv->label), font_string);
|
||||
g_free (font_string);
|
||||
|
||||
ST_WIDGET_CLASS (st_tooltip_parent_class)->style_changed (self);
|
||||
NBTK_WIDGET_CLASS (nbtk_tooltip_parent_class)->style_changed (self);
|
||||
}
|
||||
|
||||
static void
|
||||
st_tooltip_get_preferred_width (ClutterActor *self,
|
||||
gfloat for_height,
|
||||
gfloat *min_width_p,
|
||||
gfloat *natural_width_p)
|
||||
nbtk_tooltip_get_preferred_width (ClutterActor *self,
|
||||
gfloat for_height,
|
||||
gfloat *min_width_p,
|
||||
gfloat *natural_width_p)
|
||||
{
|
||||
StTooltipPrivate *priv = ST_TOOLTIP (self)->priv;
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self));
|
||||
NbtkTooltipPrivate *priv = NBTK_TOOLTIP (self)->priv;
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (self));
|
||||
gfloat min_label_w, natural_label_w;
|
||||
gfloat label_height, arrow_height;
|
||||
ClutterActor *arrow_image;
|
||||
|
||||
st_theme_node_adjust_for_height (theme_node, &for_height);
|
||||
shell_theme_node_adjust_for_height (theme_node, &for_height);
|
||||
|
||||
arrow_image = st_widget_get_background_image (ST_WIDGET (self));
|
||||
arrow_image = nbtk_widget_get_background_image (NBTK_WIDGET (self));
|
||||
if (arrow_image)
|
||||
{
|
||||
clutter_actor_get_preferred_height (arrow_image,
|
||||
@ -189,24 +188,24 @@ st_tooltip_get_preferred_width (ClutterActor *self,
|
||||
natural_label_w = 0;
|
||||
}
|
||||
|
||||
st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p);
|
||||
shell_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p);
|
||||
}
|
||||
|
||||
static void
|
||||
st_tooltip_get_preferred_height (ClutterActor *self,
|
||||
gfloat for_width,
|
||||
gfloat *min_height_p,
|
||||
gfloat *natural_height_p)
|
||||
nbtk_tooltip_get_preferred_height (ClutterActor *self,
|
||||
gfloat for_width,
|
||||
gfloat *min_height_p,
|
||||
gfloat *natural_height_p)
|
||||
{
|
||||
StTooltipPrivate *priv = ST_TOOLTIP (self)->priv;
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self));
|
||||
NbtkTooltipPrivate *priv = NBTK_TOOLTIP (self)->priv;
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (self));
|
||||
gfloat arrow_height;
|
||||
gfloat min_label_h, natural_label_h;
|
||||
ClutterActor *arrow_image;
|
||||
|
||||
st_theme_node_adjust_for_width (theme_node, &for_width);
|
||||
shell_theme_node_adjust_for_width (theme_node, &for_width);
|
||||
|
||||
arrow_image = st_widget_get_background_image (ST_WIDGET (self));
|
||||
arrow_image = nbtk_widget_get_background_image (NBTK_WIDGET (self));
|
||||
|
||||
if (arrow_image && !priv->actor_below)
|
||||
{
|
||||
@ -239,34 +238,34 @@ st_tooltip_get_preferred_height (ClutterActor *self,
|
||||
if (natural_height_p)
|
||||
*natural_height_p = arrow_height + natural_label_h;
|
||||
|
||||
st_theme_node_adjust_preferred_height (theme_node, min_height_p, natural_height_p);
|
||||
shell_theme_node_adjust_preferred_height (theme_node, min_height_p, natural_height_p);
|
||||
}
|
||||
|
||||
static void
|
||||
st_tooltip_allocate (ClutterActor *self,
|
||||
const ClutterActorBox *box,
|
||||
ClutterAllocationFlags flags)
|
||||
nbtk_tooltip_allocate (ClutterActor *self,
|
||||
const ClutterActorBox *box,
|
||||
ClutterAllocationFlags flags)
|
||||
{
|
||||
StTooltipPrivate *priv = ST_TOOLTIP (self)->priv;
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self));
|
||||
NbtkTooltipPrivate *priv = NBTK_TOOLTIP (self)->priv;
|
||||
ShellThemeNode *theme_node = nbtk_widget_get_theme_node (NBTK_WIDGET (self));
|
||||
ClutterActorBox content_box, child_box, arrow_box;
|
||||
gfloat arrow_height, arrow_width;
|
||||
ClutterActor *border_image, *arrow_image;
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_tooltip_parent_class)->allocate (self,
|
||||
box,
|
||||
flags);
|
||||
CLUTTER_ACTOR_CLASS (nbtk_tooltip_parent_class)->allocate (self,
|
||||
box,
|
||||
flags);
|
||||
|
||||
st_theme_node_get_content_box (theme_node, box, &content_box);
|
||||
shell_theme_node_get_content_box (theme_node, box, &content_box);
|
||||
|
||||
arrow_image = st_widget_get_background_image (ST_WIDGET (self));
|
||||
arrow_image = nbtk_widget_get_background_image (NBTK_WIDGET (self));
|
||||
|
||||
if (arrow_image && !priv->actor_below)
|
||||
{
|
||||
clutter_actor_get_preferred_height (arrow_image, -1, NULL, &arrow_height);
|
||||
clutter_actor_get_preferred_width (arrow_image, -1, NULL, &arrow_width);
|
||||
|
||||
arrow_box.x1 = (float)(priv->arrow_offset) - (int)(arrow_width / 2);
|
||||
arrow_box.x1 = (float) (priv->arrow_offset) - (int) (arrow_width / 2);
|
||||
arrow_box.y1 = 0;
|
||||
arrow_box.x2 = arrow_box.x1 + arrow_width;
|
||||
arrow_box.y2 = arrow_box.y1 + arrow_height;
|
||||
@ -286,7 +285,7 @@ st_tooltip_allocate (ClutterActor *self,
|
||||
/* remove the space that is used by the arrow */
|
||||
child_box.y1 += arrow_height;
|
||||
|
||||
border_image = st_widget_get_border_image (ST_WIDGET (self));
|
||||
border_image = nbtk_widget_get_border_image (NBTK_WIDGET (self));
|
||||
if (border_image)
|
||||
clutter_actor_allocate (border_image, &child_box, flags);
|
||||
|
||||
@ -301,16 +300,16 @@ st_tooltip_allocate (ClutterActor *self,
|
||||
|
||||
|
||||
static void
|
||||
st_tooltip_paint (ClutterActor *self)
|
||||
nbtk_tooltip_paint (ClutterActor *self)
|
||||
{
|
||||
ClutterActor *border_image, *arrow_image;
|
||||
StTooltipPrivate *priv = ST_TOOLTIP (self)->priv;
|
||||
NbtkTooltipPrivate *priv = NBTK_TOOLTIP (self)->priv;
|
||||
|
||||
border_image = st_widget_get_border_image (ST_WIDGET (self));
|
||||
border_image = nbtk_widget_get_border_image (NBTK_WIDGET (self));
|
||||
if (border_image)
|
||||
clutter_actor_paint (border_image);
|
||||
|
||||
arrow_image = st_widget_get_background_image (ST_WIDGET (self));
|
||||
arrow_image = nbtk_widget_get_background_image (NBTK_WIDGET (self));
|
||||
if (arrow_image && !priv->actor_below)
|
||||
clutter_actor_paint (arrow_image);
|
||||
|
||||
@ -318,18 +317,18 @@ st_tooltip_paint (ClutterActor *self)
|
||||
}
|
||||
|
||||
static void
|
||||
st_tooltip_map (ClutterActor *self)
|
||||
nbtk_tooltip_map (ClutterActor *self)
|
||||
{
|
||||
StTooltipPrivate *priv = ST_TOOLTIP (self)->priv;
|
||||
NbtkTooltipPrivate *priv = NBTK_TOOLTIP (self)->priv;
|
||||
ClutterActor *border_image, *arrow_image;
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_tooltip_parent_class)->map (self);
|
||||
CLUTTER_ACTOR_CLASS (nbtk_tooltip_parent_class)->map (self);
|
||||
|
||||
border_image = st_widget_get_border_image (ST_WIDGET (self));
|
||||
border_image = nbtk_widget_get_border_image (NBTK_WIDGET (self));
|
||||
if (border_image)
|
||||
clutter_actor_map (border_image);
|
||||
|
||||
arrow_image = st_widget_get_background_image (ST_WIDGET (self));
|
||||
arrow_image = nbtk_widget_get_background_image (NBTK_WIDGET (self));
|
||||
if (arrow_image)
|
||||
clutter_actor_map (arrow_image);
|
||||
|
||||
@ -337,18 +336,18 @@ st_tooltip_map (ClutterActor *self)
|
||||
}
|
||||
|
||||
static void
|
||||
st_tooltip_unmap (ClutterActor *self)
|
||||
nbtk_tooltip_unmap (ClutterActor *self)
|
||||
{
|
||||
StTooltipPrivate *priv = ST_TOOLTIP (self)->priv;
|
||||
NbtkTooltipPrivate *priv = NBTK_TOOLTIP (self)->priv;
|
||||
ClutterActor *border_image, *arrow_image;
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_tooltip_parent_class)->unmap (self);
|
||||
CLUTTER_ACTOR_CLASS (nbtk_tooltip_parent_class)->unmap (self);
|
||||
|
||||
border_image = st_widget_get_border_image (ST_WIDGET (self));
|
||||
border_image = nbtk_widget_get_border_image (NBTK_WIDGET (self));
|
||||
if (border_image)
|
||||
clutter_actor_unmap (border_image);
|
||||
|
||||
arrow_image = st_widget_get_background_image (ST_WIDGET (self));
|
||||
arrow_image = nbtk_widget_get_background_image (NBTK_WIDGET (self));
|
||||
if (arrow_image)
|
||||
clutter_actor_unmap (arrow_image);
|
||||
|
||||
@ -356,26 +355,26 @@ st_tooltip_unmap (ClutterActor *self)
|
||||
}
|
||||
|
||||
static void
|
||||
st_tooltip_class_init (StTooltipClass *klass)
|
||||
nbtk_tooltip_class_init (NbtkTooltipClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
||||
StWidgetClass *widget_class = ST_WIDGET_CLASS (klass);
|
||||
NbtkWidgetClass *widget_class = NBTK_WIDGET_CLASS (klass);
|
||||
GParamSpec *pspec;
|
||||
|
||||
g_type_class_add_private (klass, sizeof (StTooltipPrivate));
|
||||
g_type_class_add_private (klass, sizeof (NbtkTooltipPrivate));
|
||||
|
||||
gobject_class->set_property = st_tooltip_set_property;
|
||||
gobject_class->get_property = st_tooltip_get_property;
|
||||
gobject_class->set_property = nbtk_tooltip_set_property;
|
||||
gobject_class->get_property = nbtk_tooltip_get_property;
|
||||
|
||||
actor_class->get_preferred_width = st_tooltip_get_preferred_width;
|
||||
actor_class->get_preferred_height = st_tooltip_get_preferred_height;
|
||||
actor_class->allocate = st_tooltip_allocate;
|
||||
actor_class->paint = st_tooltip_paint;
|
||||
actor_class->map = st_tooltip_map;
|
||||
actor_class->unmap = st_tooltip_unmap;
|
||||
actor_class->get_preferred_width = nbtk_tooltip_get_preferred_width;
|
||||
actor_class->get_preferred_height = nbtk_tooltip_get_preferred_height;
|
||||
actor_class->allocate = nbtk_tooltip_allocate;
|
||||
actor_class->paint = nbtk_tooltip_paint;
|
||||
actor_class->map = nbtk_tooltip_map;
|
||||
actor_class->unmap = nbtk_tooltip_unmap;
|
||||
|
||||
widget_class->style_changed = st_tooltip_style_changed;
|
||||
widget_class->style_changed = nbtk_tooltip_style_changed;
|
||||
|
||||
pspec = g_param_spec_string ("label",
|
||||
"Label",
|
||||
@ -387,14 +386,14 @@ st_tooltip_class_init (StTooltipClass *klass)
|
||||
"Tip Area",
|
||||
"Area on the stage the tooltip applies to",
|
||||
CLUTTER_TYPE_GEOMETRY,
|
||||
ST_PARAM_READWRITE);
|
||||
NBTK_PARAM_READWRITE);
|
||||
g_object_class_install_property (gobject_class, PROP_TIP_AREA, pspec);
|
||||
}
|
||||
|
||||
static void
|
||||
st_tooltip_init (StTooltip *tooltip)
|
||||
nbtk_tooltip_init (NbtkTooltip *tooltip)
|
||||
{
|
||||
tooltip->priv = ST_TOOLTIP_GET_PRIVATE (tooltip);
|
||||
tooltip->priv = NBTK_TOOLTIP_GET_PRIVATE (tooltip);
|
||||
|
||||
tooltip->priv->label = g_object_new (CLUTTER_TYPE_TEXT,
|
||||
"line-alignment", PANGO_ALIGN_CENTER,
|
||||
@ -413,9 +412,9 @@ st_tooltip_init (StTooltip *tooltip)
|
||||
}
|
||||
|
||||
static void
|
||||
st_tooltip_update_position (StTooltip *tooltip)
|
||||
nbtk_tooltip_update_position (NbtkTooltip *tooltip)
|
||||
{
|
||||
StTooltipPrivate *priv = tooltip->priv;
|
||||
NbtkTooltipPrivate *priv = tooltip->priv;
|
||||
ClutterGeometry *tip_area = tooltip->priv->tip_area;
|
||||
gfloat tooltip_w, tooltip_h, tooltip_x, tooltip_y;
|
||||
gfloat stage_w, stage_h;
|
||||
@ -433,14 +432,14 @@ st_tooltip_update_position (StTooltip *tooltip)
|
||||
|
||||
/* we need to have a style in case there are padding/border values to take into
|
||||
* account when calculating width/height */
|
||||
st_widget_ensure_style ((StWidget *) tooltip);
|
||||
nbtk_widget_ensure_style ((NbtkWidget *) tooltip);
|
||||
|
||||
/* find out the tooltip's size */
|
||||
clutter_actor_get_size ((ClutterActor*) tooltip, &tooltip_w, &tooltip_h);
|
||||
|
||||
/* attempt to place the tooltip */
|
||||
tooltip_x = (int)(tip_area->x + (tip_area->width / 2) - (tooltip_w / 2));
|
||||
tooltip_y = (int)(tip_area->y + tip_area->height);
|
||||
tooltip_x = (int) (tip_area->x + (tip_area->width / 2) - (tooltip_w / 2));
|
||||
tooltip_y = (int) (tip_area->y + tip_area->height);
|
||||
|
||||
stage = clutter_actor_get_stage ((ClutterActor *) tooltip);
|
||||
if (!stage)
|
||||
@ -461,7 +460,7 @@ st_tooltip_update_position (StTooltip *tooltip)
|
||||
}
|
||||
else if (tooltip_x + tooltip_w > stage_w)
|
||||
{
|
||||
tooltip_x = (int)(stage_w) - tooltip_w;
|
||||
tooltip_x = (int) (stage_w) - tooltip_w;
|
||||
}
|
||||
|
||||
/* make sure the tooltip is not off screen horizontally */
|
||||
@ -486,35 +485,35 @@ st_tooltip_update_position (StTooltip *tooltip)
|
||||
}
|
||||
|
||||
/**
|
||||
* st_tooltip_get_label:
|
||||
* @tooltip: a #StTooltip
|
||||
* nbtk_tooltip_get_label:
|
||||
* @tooltip: a #NbtkTooltip
|
||||
*
|
||||
* Get the text displayed on the tooltip
|
||||
*
|
||||
* Returns: the text for the tooltip. This must not be freed by the application
|
||||
*/
|
||||
G_CONST_RETURN gchar *
|
||||
st_tooltip_get_label (StTooltip *tooltip)
|
||||
nbtk_tooltip_get_label (NbtkTooltip *tooltip)
|
||||
{
|
||||
g_return_val_if_fail (ST_IS_TOOLTIP (tooltip), NULL);
|
||||
g_return_val_if_fail (NBTK_IS_TOOLTIP (tooltip), NULL);
|
||||
|
||||
return clutter_text_get_text (CLUTTER_TEXT (tooltip->priv->label));
|
||||
}
|
||||
|
||||
/**
|
||||
* st_tooltip_set_label:
|
||||
* @tooltip: a #StTooltip
|
||||
* nbtk_tooltip_set_label:
|
||||
* @tooltip: a #NbtkTooltip
|
||||
* @text: text to set the label to
|
||||
*
|
||||
* Sets the text displayed on the tooltip
|
||||
*/
|
||||
void
|
||||
st_tooltip_set_label (StTooltip *tooltip,
|
||||
const gchar *text)
|
||||
nbtk_tooltip_set_label (NbtkTooltip *tooltip,
|
||||
const gchar *text)
|
||||
{
|
||||
StTooltipPrivate *priv;
|
||||
NbtkTooltipPrivate *priv;
|
||||
|
||||
g_return_if_fail (ST_IS_TOOLTIP (tooltip));
|
||||
g_return_if_fail (NBTK_IS_TOOLTIP (tooltip));
|
||||
|
||||
priv = tooltip->priv;
|
||||
|
||||
@ -524,15 +523,15 @@ st_tooltip_set_label (StTooltip *tooltip,
|
||||
}
|
||||
|
||||
/**
|
||||
* st_tooltip_show:
|
||||
* @tooltip: a #StTooltip
|
||||
* nbtk_tooltip_show:
|
||||
* @tooltip: a #NbtkTooltip
|
||||
*
|
||||
* Show the tooltip relative to the associated widget.
|
||||
*/
|
||||
void
|
||||
st_tooltip_show (StTooltip *tooltip)
|
||||
nbtk_tooltip_show (NbtkTooltip *tooltip)
|
||||
{
|
||||
StTooltipPrivate *priv;
|
||||
NbtkTooltipPrivate *priv;
|
||||
ClutterActor *parent;
|
||||
ClutterActor *stage;
|
||||
ClutterActor *self = CLUTTER_ACTOR (tooltip);
|
||||
@ -549,7 +548,7 @@ st_tooltip_show (StTooltip *tooltip)
|
||||
|
||||
if (!stage)
|
||||
{
|
||||
g_warning ("StTooltip is not on any stage.");
|
||||
g_warning ("NbtkTooltip is not on any stage.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -568,10 +567,10 @@ st_tooltip_show (StTooltip *tooltip)
|
||||
CLUTTER_ACTOR (tooltip),
|
||||
NULL);
|
||||
|
||||
st_tooltip_update_position (tooltip);
|
||||
nbtk_tooltip_update_position (tooltip);
|
||||
|
||||
/* finally show the tooltip... */
|
||||
CLUTTER_ACTOR_CLASS (st_tooltip_parent_class)->show (self);
|
||||
CLUTTER_ACTOR_CLASS (nbtk_tooltip_parent_class)->show (self);
|
||||
|
||||
/* and give it some bounce! */
|
||||
g_object_set (G_OBJECT (self),
|
||||
@ -587,27 +586,27 @@ st_tooltip_show (StTooltip *tooltip)
|
||||
}
|
||||
|
||||
static void
|
||||
st_tooltip_hide_complete (ClutterAnimation *animation,
|
||||
ClutterActor *actor)
|
||||
nbtk_tooltip_hide_complete (ClutterAnimation *animation,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
CLUTTER_ACTOR_CLASS (st_tooltip_parent_class)->hide (actor);
|
||||
CLUTTER_ACTOR_CLASS (nbtk_tooltip_parent_class)->hide (actor);
|
||||
g_signal_handlers_disconnect_by_func (actor,
|
||||
st_tooltip_hide_complete,
|
||||
nbtk_tooltip_hide_complete,
|
||||
actor);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_tooltip_hide:
|
||||
* @tooltip: a #StTooltip
|
||||
* nbtk_tooltip_hide:
|
||||
* @tooltip: a #NbtkTooltip
|
||||
*
|
||||
* Hide the tooltip
|
||||
*/
|
||||
void
|
||||
st_tooltip_hide (StTooltip *tooltip)
|
||||
nbtk_tooltip_hide (NbtkTooltip *tooltip)
|
||||
{
|
||||
ClutterAnimation *animation;
|
||||
|
||||
g_return_if_fail (ST_TOOLTIP (tooltip));
|
||||
g_return_if_fail (NBTK_TOOLTIP (tooltip));
|
||||
|
||||
/* make sure we're not currently already animating (e.g. hiding) */
|
||||
animation = clutter_actor_get_animation (CLUTTER_ACTOR (tooltip));
|
||||
@ -624,32 +623,32 @@ st_tooltip_hide (StTooltip *tooltip)
|
||||
"scale-y", 0.0,
|
||||
NULL);
|
||||
g_signal_connect (animation, "completed",
|
||||
G_CALLBACK (st_tooltip_hide_complete), tooltip);
|
||||
G_CALLBACK (nbtk_tooltip_hide_complete), tooltip);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_tooltip_set_tip_area:
|
||||
* @tooltip: A #StTooltip
|
||||
* nbtk_tooltip_set_tip_area:
|
||||
* @tooltip: A #NbtkTooltip
|
||||
* @area: A #ClutterGeometry
|
||||
*
|
||||
* Set the area on the stage that the tooltip applies to.
|
||||
*/
|
||||
void
|
||||
st_tooltip_set_tip_area (StTooltip *tooltip,
|
||||
const ClutterGeometry *area)
|
||||
nbtk_tooltip_set_tip_area (NbtkTooltip *tooltip,
|
||||
const ClutterGeometry *area)
|
||||
{
|
||||
g_return_if_fail (ST_IS_TOOLTIP (tooltip));
|
||||
g_return_if_fail (NBTK_IS_TOOLTIP (tooltip));
|
||||
|
||||
if (tooltip->priv->tip_area)
|
||||
g_boxed_free (CLUTTER_TYPE_GEOMETRY, tooltip->priv->tip_area);
|
||||
tooltip->priv->tip_area = g_boxed_copy (CLUTTER_TYPE_GEOMETRY, area);
|
||||
|
||||
st_tooltip_update_position (tooltip);
|
||||
nbtk_tooltip_update_position (tooltip);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_tooltip_get_tip_area:
|
||||
* @tooltip: A #StTooltip
|
||||
* nbtk_tooltip_get_tip_area:
|
||||
* @tooltip: A #NbtkTooltip
|
||||
*
|
||||
* Retrieve the area on the stage that the tooltip currently applies to
|
||||
*
|
||||
@ -657,9 +656,9 @@ st_tooltip_set_tip_area (StTooltip *tooltip,
|
||||
* by the application.
|
||||
*/
|
||||
G_CONST_RETURN ClutterGeometry*
|
||||
st_tooltip_get_tip_area (StTooltip *tooltip)
|
||||
nbtk_tooltip_get_tip_area (NbtkTooltip *tooltip)
|
||||
{
|
||||
g_return_val_if_fail (ST_IS_TOOLTIP (tooltip), NULL);
|
||||
g_return_val_if_fail (NBTK_IS_TOOLTIP (tooltip), NULL);
|
||||
|
||||
return tooltip->priv->tip_area;
|
||||
}
|
79
src/nbtk/nbtk-tooltip.h
Normal file
79
src/nbtk/nbtk-tooltip.h
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* nbtk-tooltip.h: Plain tooltip actor
|
||||
*
|
||||
* Copyright 2008, 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Written by: Thomas Wood <thomas@linux.intel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(NBTK_H_INSIDE) && !defined(NBTK_COMPILATION)
|
||||
#error "Only <nbtk/nbtk.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef __NBTK_TOOLTIP_H__
|
||||
#define __NBTK_TOOLTIP_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#include <nbtk/nbtk-bin.h>
|
||||
|
||||
#define NBTK_TYPE_TOOLTIP (nbtk_tooltip_get_type ())
|
||||
#define NBTK_TOOLTIP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NBTK_TYPE_TOOLTIP, NbtkTooltip))
|
||||
#define NBTK_IS_TOOLTIP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NBTK_TYPE_TOOLTIP))
|
||||
#define NBTK_TOOLTIP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NBTK_TYPE_TOOLTIP, NbtkTooltipClass))
|
||||
#define NBTK_IS_TOOLTIP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NBTK_TYPE_TOOLTIP))
|
||||
#define NBTK_TOOLTIP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NBTK_TYPE_TOOLTIP, NbtkTooltipClass))
|
||||
|
||||
typedef struct _NbtkTooltip NbtkTooltip;
|
||||
typedef struct _NbtkTooltipPrivate NbtkTooltipPrivate;
|
||||
typedef struct _NbtkTooltipClass NbtkTooltipClass;
|
||||
|
||||
/**
|
||||
* NbtkTooltip:
|
||||
*
|
||||
* The contents of this structure is private and should only be accessed using
|
||||
* the provided API.
|
||||
*/
|
||||
struct _NbtkTooltip
|
||||
{
|
||||
/*< private >*/
|
||||
NbtkBin parent_instance;
|
||||
|
||||
NbtkTooltipPrivate *priv;
|
||||
};
|
||||
|
||||
struct _NbtkTooltipClass
|
||||
{
|
||||
NbtkBinClass parent_class;
|
||||
};
|
||||
|
||||
GType nbtk_tooltip_get_type (void) G_GNUC_CONST;
|
||||
|
||||
G_CONST_RETURN gchar *nbtk_tooltip_get_label (NbtkTooltip *tooltip);
|
||||
void nbtk_tooltip_set_label (NbtkTooltip *tooltip,
|
||||
const gchar *text);
|
||||
void nbtk_tooltip_show (NbtkTooltip *tooltip);
|
||||
void nbtk_tooltip_hide (NbtkTooltip *tooltip);
|
||||
|
||||
void nbtk_tooltip_set_tip_area (NbtkTooltip *tooltip, const ClutterGeometry *area);
|
||||
G_CONST_RETURN ClutterGeometry* nbtk_tooltip_get_tip_area (NbtkTooltip *tooltip);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NBTK_TOOLTIP_H__ */
|
@ -1,4 +1,3 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
@ -17,32 +16,44 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:st-types
|
||||
* @short_description: type definitions used throughout St
|
||||
*
|
||||
* Common types for StWidgets.
|
||||
*/
|
||||
|
||||
|
||||
#if !defined(ST_H_INSIDE) && !defined(ST_COMPILATION)
|
||||
#error "Only <st/st.h> can be included directly.h"
|
||||
#if !defined(NBTK_H_INSIDE) && !defined(NBTK_COMPILATION)
|
||||
#error "Only <nbtk/nbtk.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef __ST_TYPES_H__
|
||||
#define __ST_TYPES_H__
|
||||
#ifndef __NBTK_TYPES_H__
|
||||
#define __NBTK_TYPES_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NBTK_TYPE_PADDING (nbtk_padding_get_type ())
|
||||
|
||||
/**
|
||||
* NbtkAlignment:
|
||||
* @NBTK_ALIGN_TOP: align to the top (vertically)
|
||||
* @NBTK_ALIGN_RIGHT: align to the right (horizontally)
|
||||
* @NBTK_ALIGN_BOTTOM: align to the bottom (vertically)
|
||||
* @NBTK_ALIGN_LEFT: align to the left (horizontally)
|
||||
* @NBTK_ALIGN_CENTER: align to the center (horizontally or vertically)
|
||||
*
|
||||
* The alignment values for a #NbtkBin.
|
||||
*/
|
||||
typedef enum {
|
||||
ST_ALIGN_START,
|
||||
ST_ALIGN_MIDDLE,
|
||||
ST_ALIGN_END
|
||||
} StAlign;
|
||||
NBTK_ALIGN_TOP,
|
||||
NBTK_ALIGN_RIGHT,
|
||||
NBTK_ALIGN_BOTTOM,
|
||||
NBTK_ALIGN_LEFT,
|
||||
NBTK_ALIGN_CENTER
|
||||
} NbtkAlignment;
|
||||
|
||||
typedef enum {
|
||||
NBTK_ALIGN_START,
|
||||
NBTK_ALIGN_MIDDLE,
|
||||
NBTK_ALIGN_END
|
||||
} NbtkAlign;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __ST_TYPES_H__ */
|
||||
#endif /* __NBTK_TYPES_H__ */
|
File diff suppressed because it is too large
Load Diff
116
src/nbtk/nbtk-widget.h
Normal file
116
src/nbtk/nbtk-widget.h
Normal file
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* nbtk-widget.h: Base class for Nbtk actors
|
||||
*
|
||||
* Copyright 2007 OpenedHand
|
||||
* Copyright 2008, 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(NBTK_H_INSIDE) && !defined(NBTK_COMPILATION)
|
||||
#error "Only <nbtk/nbtk.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef __NBTK_WIDGET_H__
|
||||
#define __NBTK_WIDGET_H__
|
||||
|
||||
#include <clutter/clutter.h>
|
||||
#include <nbtk/nbtk-types.h>
|
||||
#include <toolkit/shell-theme.h>
|
||||
#include <toolkit/shell-theme-node.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NBTK_TYPE_WIDGET (nbtk_widget_get_type ())
|
||||
#define NBTK_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NBTK_TYPE_WIDGET, NbtkWidget))
|
||||
#define NBTK_IS_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NBTK_TYPE_WIDGET))
|
||||
#define NBTK_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NBTK_TYPE_WIDGET, NbtkWidgetClass))
|
||||
#define NBTK_IS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NBTK_TYPE_WIDGET))
|
||||
#define NBTK_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NBTK_TYPE_WIDGET, NbtkWidgetClass))
|
||||
|
||||
typedef struct _NbtkWidget NbtkWidget;
|
||||
typedef struct _NbtkWidgetPrivate NbtkWidgetPrivate;
|
||||
typedef struct _NbtkWidgetClass NbtkWidgetClass;
|
||||
|
||||
/**
|
||||
* NbtkWidget:
|
||||
*
|
||||
* Base class for stylable actors. The contents of the #NbtkWidget
|
||||
* structure are private and should only be accessed through the
|
||||
* public API.
|
||||
*/
|
||||
struct _NbtkWidget
|
||||
{
|
||||
/*< private >*/
|
||||
ClutterActor parent_instance;
|
||||
|
||||
NbtkWidgetPrivate *priv;
|
||||
};
|
||||
|
||||
/**
|
||||
* NbtkWidgetClass:
|
||||
*
|
||||
* Base class for stylable actors.
|
||||
*/
|
||||
struct _NbtkWidgetClass
|
||||
{
|
||||
/*< private >*/
|
||||
ClutterActorClass parent_class;
|
||||
|
||||
/* vfuncs */
|
||||
void (* draw_background) (NbtkWidget *self);
|
||||
void (* style_changed) (NbtkWidget *self);
|
||||
};
|
||||
|
||||
GType nbtk_widget_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void nbtk_widget_set_style_pseudo_class (NbtkWidget *actor,
|
||||
const gchar *pseudo_class);
|
||||
G_CONST_RETURN gchar *nbtk_widget_get_style_pseudo_class (NbtkWidget *actor);
|
||||
void nbtk_widget_set_style_class_name (NbtkWidget *actor,
|
||||
const gchar *style_class);
|
||||
G_CONST_RETURN gchar *nbtk_widget_get_style_class_name (NbtkWidget *actor);
|
||||
void nbtk_widget_set_style (NbtkWidget *actor,
|
||||
const gchar *style);
|
||||
G_CONST_RETURN gchar *nbtk_widget_get_style (NbtkWidget *actor);
|
||||
|
||||
void nbtk_widget_set_theme (NbtkWidget *actor,
|
||||
ShellTheme *theme);
|
||||
ShellTheme *nbtk_widget_get_theme (NbtkWidget *actor);
|
||||
|
||||
void nbtk_widget_set_has_tooltip (NbtkWidget *widget, gboolean has_tooltip);
|
||||
gboolean nbtk_widget_get_has_tooltip (NbtkWidget *widget);
|
||||
void nbtk_widget_set_tooltip_text (NbtkWidget *widget, const gchar *text);
|
||||
const gchar* nbtk_widget_get_tooltip_text (NbtkWidget *widget);
|
||||
|
||||
void nbtk_widget_show_tooltip (NbtkWidget *widget);
|
||||
void nbtk_widget_hide_tooltip (NbtkWidget *widget);
|
||||
|
||||
void nbtk_widget_ensure_style (NbtkWidget *widget);
|
||||
|
||||
|
||||
/* Only to be used by sub-classes of NbtkWidget */
|
||||
void nbtk_widget_style_changed (NbtkWidget *widget);
|
||||
|
||||
ShellThemeNode *nbtk_widget_get_theme_node (NbtkWidget *widget);
|
||||
|
||||
ClutterActor *nbtk_widget_get_background_image (NbtkWidget *actor);
|
||||
ClutterActor *nbtk_widget_get_border_image (NbtkWidget *actor);
|
||||
void nbtk_widget_draw_background (NbtkWidget *widget);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NBTK_WIDGET_H__ */
|
236
src/shell-alttab.c
Normal file
236
src/shell-alttab.c
Normal file
@ -0,0 +1,236 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
#include "shell-alttab.h"
|
||||
#include "shell-global.h"
|
||||
#include "shell-wm.h"
|
||||
#include <mutter-plugin.h>
|
||||
|
||||
/* Our MetaAltTabHandler implementation; ideally we would implement
|
||||
* this directly from JavaScript, but for now we can't. So we register
|
||||
* this glue class as our MetaAltTabHandler and then when mutter
|
||||
* creates one, we pass it on to ShellWM, which emits a signal to hand
|
||||
* it off to javascript code, which then connects to the signals on
|
||||
* this object.
|
||||
*/
|
||||
|
||||
static void shell_alt_tab_handler_interface_init (MetaAltTabHandlerInterface *handler_iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (ShellAltTabHandler, shell_alt_tab_handler, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (META_TYPE_ALT_TAB_HANDLER,
|
||||
shell_alt_tab_handler_interface_init))
|
||||
|
||||
/* Signals */
|
||||
enum
|
||||
{
|
||||
WINDOW_ADDED,
|
||||
SHOW,
|
||||
DESTROY,
|
||||
|
||||
LAST_SIGNAL
|
||||
};
|
||||
static guint signals [LAST_SIGNAL] = { 0 };
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_SELECTED = 1,
|
||||
PROP_SCREEN,
|
||||
PROP_IMMEDIATE
|
||||
};
|
||||
|
||||
static void
|
||||
shell_alt_tab_handler_init (ShellAltTabHandler *sth)
|
||||
{
|
||||
sth->windows = g_ptr_array_new ();
|
||||
sth->selected = -1;
|
||||
}
|
||||
|
||||
static void
|
||||
shell_alt_tab_handler_constructed (GObject *object)
|
||||
{
|
||||
ShellGlobal *global = shell_global_get ();
|
||||
ShellWM *wm;
|
||||
|
||||
g_object_get (G_OBJECT (global), "window-manager", &wm, NULL);
|
||||
_shell_wm_begin_alt_tab (wm, SHELL_ALT_TAB_HANDLER (object));
|
||||
g_object_unref (wm);
|
||||
}
|
||||
|
||||
static void
|
||||
shell_alt_tab_handler_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ShellAltTabHandler *sth = SHELL_ALT_TAB_HANDLER (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_SCREEN:
|
||||
/* We don't care */
|
||||
break;
|
||||
case PROP_IMMEDIATE:
|
||||
sth->immediate_mode = g_value_get_boolean (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
shell_alt_tab_handler_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ShellAltTabHandler *sth = SHELL_ALT_TAB_HANDLER (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_SELECTED:
|
||||
g_value_set_int (value, sth->selected);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
shell_alt_tab_handler_finalize (GObject *object)
|
||||
{
|
||||
ShellAltTabHandler *sth = SHELL_ALT_TAB_HANDLER (object);
|
||||
|
||||
g_ptr_array_free (sth->windows, FALSE);
|
||||
|
||||
G_OBJECT_CLASS (shell_alt_tab_handler_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
shell_alt_tab_handler_add_window (MetaAltTabHandler *handler,
|
||||
MetaWindow *window)
|
||||
{
|
||||
ShellAltTabHandler *sth = SHELL_ALT_TAB_HANDLER (handler);
|
||||
|
||||
g_ptr_array_add (sth->windows, window);
|
||||
g_signal_emit (handler, signals[WINDOW_ADDED], 0,
|
||||
meta_window_get_compositor_private (window));
|
||||
}
|
||||
|
||||
static void
|
||||
shell_alt_tab_handler_show (MetaAltTabHandler *handler,
|
||||
MetaWindow *initial_selection)
|
||||
{
|
||||
ShellAltTabHandler *sth = SHELL_ALT_TAB_HANDLER (handler);
|
||||
int i;
|
||||
|
||||
sth->selected = -1;
|
||||
for (i = 0; i < sth->windows->len; i++)
|
||||
{
|
||||
if (sth->windows->pdata[i] == (gpointer)initial_selection)
|
||||
{
|
||||
sth->selected = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_signal_emit (handler, signals[SHOW], 0, sth->selected);
|
||||
}
|
||||
|
||||
static void
|
||||
shell_alt_tab_handler_destroy (MetaAltTabHandler *handler)
|
||||
{
|
||||
g_signal_emit (handler, signals[DESTROY], 0);
|
||||
}
|
||||
|
||||
static void
|
||||
shell_alt_tab_handler_forward (MetaAltTabHandler *handler)
|
||||
{
|
||||
ShellAltTabHandler *sth = SHELL_ALT_TAB_HANDLER (handler);
|
||||
|
||||
if (sth->selected == sth->windows->len - 1)
|
||||
sth->selected = 0;
|
||||
else
|
||||
sth->selected++;
|
||||
g_object_notify (G_OBJECT (handler), "selected");
|
||||
}
|
||||
|
||||
static void
|
||||
shell_alt_tab_handler_backward (MetaAltTabHandler *handler)
|
||||
{
|
||||
ShellAltTabHandler *sth = SHELL_ALT_TAB_HANDLER (handler);
|
||||
|
||||
if (sth->selected == 0)
|
||||
sth->selected = sth->windows->len - 1;
|
||||
else
|
||||
sth->selected--;
|
||||
g_object_notify (G_OBJECT (handler), "selected");
|
||||
}
|
||||
|
||||
static MetaWindow *
|
||||
shell_alt_tab_handler_get_selected (MetaAltTabHandler *handler)
|
||||
{
|
||||
ShellAltTabHandler *sth = SHELL_ALT_TAB_HANDLER (handler);
|
||||
|
||||
if (sth->selected > -1)
|
||||
return sth->windows->pdata[sth->selected];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
shell_alt_tab_handler_class_init (ShellAltTabHandlerClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->constructed = shell_alt_tab_handler_constructed;
|
||||
object_class->set_property = shell_alt_tab_handler_set_property;
|
||||
object_class->get_property = shell_alt_tab_handler_get_property;
|
||||
object_class->finalize = shell_alt_tab_handler_finalize;
|
||||
|
||||
g_object_class_override_property (object_class, PROP_SCREEN, "screen");
|
||||
g_object_class_override_property (object_class, PROP_IMMEDIATE, "immediate");
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_SELECTED,
|
||||
g_param_spec_int ("selected",
|
||||
"Selected",
|
||||
"Selected window",
|
||||
-1, G_MAXINT, -1,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
|
||||
signals[WINDOW_ADDED] = g_signal_new ("window-added",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0,
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE, 1,
|
||||
MUTTER_TYPE_COMP_WINDOW);
|
||||
signals[SHOW] = g_signal_new ("show",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0,
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__INT,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_INT);
|
||||
signals[DESTROY] = g_signal_new ("destroy",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0,
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
shell_alt_tab_handler_interface_init (MetaAltTabHandlerInterface *handler_iface)
|
||||
{
|
||||
handler_iface->add_window = shell_alt_tab_handler_add_window;
|
||||
handler_iface->show = shell_alt_tab_handler_show;
|
||||
handler_iface->destroy = shell_alt_tab_handler_destroy;
|
||||
handler_iface->forward = shell_alt_tab_handler_forward;
|
||||
handler_iface->backward = shell_alt_tab_handler_backward;
|
||||
handler_iface->get_selected = shell_alt_tab_handler_get_selected;
|
||||
}
|
34
src/shell-alttab.h
Normal file
34
src/shell-alttab.h
Normal file
@ -0,0 +1,34 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
#ifndef SHELL_ALT_TAB_HANDLER_H
|
||||
#define SHELL_ALT_TAB_HANDLER_H
|
||||
|
||||
#include <alttabhandler.h>
|
||||
|
||||
#define SHELL_TYPE_ALT_TAB_HANDLER (shell_alt_tab_handler_get_type ())
|
||||
#define SHELL_ALT_TAB_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SHELL_TYPE_ALT_TAB_HANDLER, ShellAltTabHandler))
|
||||
#define SHELL_ALT_TAB_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SHELL_TYPE_ALT_TAB_HANDLER, ShellAltTabHandlerClass))
|
||||
#define SHELL_IS_ALT_TAB_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SHELL_ALT_TAB_HANDLER_TYPE))
|
||||
#define SHELL_IS_ALT_TAB_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SHELL_TYPE_ALT_TAB_HANDLER))
|
||||
#define SHELL_ALT_TAB_HANDLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SHELL_TYPE_ALT_TAB_HANDLER, ShellAltTabHandlerClass))
|
||||
|
||||
typedef struct _ShellAltTabHandler ShellAltTabHandler;
|
||||
typedef struct _ShellAltTabHandlerClass ShellAltTabHandlerClass;
|
||||
|
||||
struct _ShellAltTabHandler {
|
||||
GObject parent_instance;
|
||||
|
||||
GPtrArray *windows;
|
||||
int selected;
|
||||
gboolean immediate_mode;
|
||||
};
|
||||
|
||||
struct _ShellAltTabHandlerClass {
|
||||
GObjectClass parent_class;
|
||||
|
||||
};
|
||||
|
||||
GType shell_alt_tab_handler_get_type (void);
|
||||
|
||||
#endif
|
||||
|
@ -1039,7 +1039,6 @@ shell_app_monitor_init (ShellAppMonitor *self)
|
||||
path = g_build_filename (shell_config_dir, DATA_FILENAME, NULL);
|
||||
g_free (shell_config_dir);
|
||||
self->configfile = g_file_new_for_path (path);
|
||||
g_free (path);
|
||||
restore_from_file (self);
|
||||
|
||||
load_initial_windows (self);
|
||||
|
@ -539,7 +539,7 @@ shell_app_menu_entry_get_type (void)
|
||||
* Traverses a toplevel menu, and returns all items under it. Nested items
|
||||
* are flattened.
|
||||
*
|
||||
* Return value: (transfer full) (element-type ShellAppInfo): List of applications
|
||||
* Return value: (transfer container) (element-type ShellAppInfo): List of applications
|
||||
*/
|
||||
GSList *
|
||||
shell_app_system_get_applications_for_menu (ShellAppSystem *monitor,
|
||||
@ -984,18 +984,14 @@ shell_app_info_create_icon_texture (ShellAppInfo *info, float size)
|
||||
}
|
||||
|
||||
icon = shell_app_info_get_icon (info);
|
||||
if (icon == NULL)
|
||||
if (!icon)
|
||||
{
|
||||
ret = clutter_texture_new ();
|
||||
g_object_set (ret, "opacity", 0, "width", size, "height", size, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = shell_texture_cache_load_gicon (shell_texture_cache_get_default (), icon, (int)size);
|
||||
g_object_unref (icon);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return shell_texture_cache_load_gicon (shell_texture_cache_get_default (), icon, (int)size);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -148,16 +148,12 @@ shell_draw_clock (ClutterCairoTexture *texture,
|
||||
|
||||
void
|
||||
shell_draw_box_pointer (ClutterCairoTexture *texture,
|
||||
ClutterGravity pointing_towards,
|
||||
ClutterColor *border_color,
|
||||
ClutterColor *background_color)
|
||||
{
|
||||
guint width, height;
|
||||
cairo_t *cr;
|
||||
|
||||
g_return_if_fail (pointing_towards == CLUTTER_GRAVITY_NORTH ||
|
||||
pointing_towards == CLUTTER_GRAVITY_WEST);
|
||||
|
||||
clutter_cairo_texture_get_surface_size (texture, &width, &height);
|
||||
|
||||
clutter_cairo_texture_clear (texture);
|
||||
@ -167,18 +163,9 @@ shell_draw_box_pointer (ClutterCairoTexture *texture,
|
||||
|
||||
clutter_cairo_set_source_color (cr, border_color);
|
||||
|
||||
if (pointing_towards == CLUTTER_GRAVITY_WEST)
|
||||
{
|
||||
cairo_move_to (cr, width, 0);
|
||||
cairo_line_to (cr, 0, floor (height * 0.5));
|
||||
cairo_line_to (cr, width, height);
|
||||
}
|
||||
else /* CLUTTER_GRAVITY_NORTH */
|
||||
{
|
||||
cairo_move_to (cr, 0, height);
|
||||
cairo_line_to (cr, floor (width * 0.5), 0);
|
||||
cairo_line_to (cr, width, height);
|
||||
}
|
||||
cairo_move_to (cr, width, 0);
|
||||
cairo_line_to (cr, 0, floor (height * 0.5));
|
||||
cairo_line_to (cr, width, height);
|
||||
|
||||
cairo_stroke_preserve (cr);
|
||||
|
||||
@ -196,20 +183,25 @@ hook_paint_red_border (ClutterActor *actor,
|
||||
CoglColor color;
|
||||
ClutterGeometry geom;
|
||||
float width = 2;
|
||||
float x2;
|
||||
float y2;
|
||||
|
||||
cogl_color_set_from_4ub (&color, 0xff, 0, 0, 0xc4);
|
||||
cogl_set_source_color (&color);
|
||||
|
||||
clutter_actor_get_allocation_geometry (actor, &geom);
|
||||
x2 = geom.x + geom.width;
|
||||
y2 = geom.y + geom.height;
|
||||
|
||||
/** clockwise order **/
|
||||
cogl_rectangle (0, 0, geom.width, width);
|
||||
cogl_rectangle (geom.width - width, width,
|
||||
geom.width, geom.height);
|
||||
cogl_rectangle (0, geom.height,
|
||||
geom.width - width, geom.height - width);
|
||||
cogl_rectangle (0, geom.height - width,
|
||||
width, width);
|
||||
cogl_rectangle (geom.x, geom.y,
|
||||
x2, geom.y + width);
|
||||
cogl_rectangle (x2 - width, geom.y + width,
|
||||
x2, y2);
|
||||
cogl_rectangle (x2 - width, y2,
|
||||
geom.x, y2 - width);
|
||||
cogl_rectangle (geom.x + width, y2 - width,
|
||||
geom.x, geom.y + width);
|
||||
}
|
||||
|
||||
guint
|
||||
|
@ -14,7 +14,6 @@ ClutterCairoTexture *shell_create_horizontal_gradient (ClutterColor *left,
|
||||
ClutterColor *right);
|
||||
|
||||
void shell_draw_box_pointer (ClutterCairoTexture *texture,
|
||||
ClutterGravity pointing_towards,
|
||||
ClutterColor *border_color,
|
||||
ClutterColor *background_color);
|
||||
|
||||
|
@ -2,4 +2,3 @@ VOID:INT,INT,INT
|
||||
VOID:OBJECT,INT,INT,INT,INT
|
||||
VOID:BOXED
|
||||
VOID:BOXED,OBJECT
|
||||
VOID:STRING,OBJECT,BOOLEAN
|
||||
|
@ -24,23 +24,6 @@ struct _ShellOverflowListPrivate {
|
||||
guint displayed_count;
|
||||
};
|
||||
|
||||
static GList *
|
||||
get_visible_children (ShellOverflowList *self)
|
||||
{
|
||||
GList *children, *iter, *next;
|
||||
|
||||
children = clutter_container_get_children (CLUTTER_CONTAINER (self));
|
||||
for (iter = children; iter; iter = next)
|
||||
{
|
||||
ClutterActor *actor = iter->data;
|
||||
next = iter->next;
|
||||
|
||||
if (!CLUTTER_ACTOR_IS_VISIBLE (actor))
|
||||
children = g_list_delete_link (children, iter);
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
static void
|
||||
recalc_displayed_count (ShellOverflowList *self)
|
||||
{
|
||||
@ -49,7 +32,7 @@ recalc_displayed_count (ShellOverflowList *self)
|
||||
int displayed_count;
|
||||
int page, n_pages;
|
||||
|
||||
children = get_visible_children (self);
|
||||
children = clutter_container_get_children (CLUTTER_CONTAINER (self));
|
||||
n_children = g_list_length (children);
|
||||
g_list_free (children);
|
||||
|
||||
@ -153,7 +136,7 @@ shell_overflow_list_allocate (ClutterActor *actor,
|
||||
curheight = 0;
|
||||
avail_height = box->y2 - box->y1;
|
||||
|
||||
children = get_visible_children (self);
|
||||
children = clutter_container_get_children (CLUTTER_CONTAINER (self));
|
||||
n_children = g_list_length (children);
|
||||
|
||||
n_fits = 0;
|
||||
@ -206,7 +189,7 @@ shell_overflow_list_paint (ClutterActor *actor)
|
||||
GList *children, *iter;
|
||||
int i;
|
||||
|
||||
children = get_visible_children (self);
|
||||
children = clutter_container_get_children (CLUTTER_CONTAINER (self));
|
||||
|
||||
if (children == NULL)
|
||||
return;
|
||||
@ -249,7 +232,7 @@ shell_overflow_list_get_preferred_height (ClutterActor *actor,
|
||||
if (natural_height_p)
|
||||
{
|
||||
int n_children;
|
||||
children = get_visible_children (self);
|
||||
children = clutter_container_get_children (CLUTTER_CONTAINER (self));
|
||||
n_children = g_list_length (children);
|
||||
if (n_children == 0)
|
||||
*natural_height_p = 0;
|
||||
@ -271,7 +254,7 @@ shell_overflow_list_get_preferred_width (ClutterActor *actor,
|
||||
GList *iter;
|
||||
GList *children;
|
||||
|
||||
children = get_visible_children (self);
|
||||
children = clutter_container_get_children (CLUTTER_CONTAINER (self));
|
||||
|
||||
for (iter = children; iter; iter = iter->next)
|
||||
{
|
||||
@ -391,7 +374,7 @@ shell_overflow_list_get_displayed_actor (ShellOverflowList *self,
|
||||
{
|
||||
GList *children, *iter;
|
||||
|
||||
children = get_visible_children (self);
|
||||
children = clutter_container_get_children (CLUTTER_CONTAINER (self));
|
||||
|
||||
if (children == NULL)
|
||||
return NULL;
|
||||
@ -422,7 +405,7 @@ shell_overflow_list_get_actor_index (ShellOverflowList *self,
|
||||
int i;
|
||||
int result;
|
||||
|
||||
children = get_visible_children (self);
|
||||
children = clutter_container_get_children (CLUTTER_CONTAINER (self));
|
||||
|
||||
if (children == NULL)
|
||||
return -1;
|
||||
|
@ -20,13 +20,7 @@ typedef struct
|
||||
|
||||
struct _ShellTextureCachePrivate
|
||||
{
|
||||
/* Things that were loaded with a cache policy != NONE */
|
||||
GHashTable *keyed_cache; /* CacheKey -> CoglTexture* */
|
||||
/* Presently this is used to de-duplicate requests for GIcons,
|
||||
* it could in theory be extended to async URL loading and other
|
||||
* cases too.
|
||||
*/
|
||||
GHashTable *outstanding_requests; /* CacheKey -> AsyncTextureLoadData * */
|
||||
GnomeDesktopThumbnailFactory *thumbnails;
|
||||
};
|
||||
|
||||
@ -136,8 +130,6 @@ shell_texture_cache_init (ShellTextureCache *self)
|
||||
self->priv = g_new0 (ShellTextureCachePrivate, 1);
|
||||
self->priv->keyed_cache = g_hash_table_new_full (cache_key_hash, cache_key_equal,
|
||||
cache_key_destroy, cogl_handle_unref);
|
||||
self->priv->outstanding_requests = g_hash_table_new_full (cache_key_hash, cache_key_equal,
|
||||
cache_key_destroy, NULL);
|
||||
self->priv->thumbnails = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL);
|
||||
}
|
||||
|
||||
@ -435,10 +427,7 @@ impl_load_thumbnail (ShellTextureCache *cache,
|
||||
existing_thumbnail = gnome_desktop_thumbnail_factory_lookup (thumbnail_factory, uri, mtime);
|
||||
|
||||
if (existing_thumbnail != NULL)
|
||||
{
|
||||
pixbuf = gdk_pixbuf_new_from_file_at_size (existing_thumbnail, size, size, error);
|
||||
g_free (existing_thumbnail);
|
||||
}
|
||||
pixbuf = gdk_pixbuf_new_from_file_at_size (existing_thumbnail, size, size, error);
|
||||
else if (gnome_desktop_thumbnail_factory_has_valid_failed_thumbnail (thumbnail_factory, uri, mtime))
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Has failed thumbnail");
|
||||
else if (gnome_desktop_thumbnail_factory_can_thumbnail (thumbnail_factory, uri, mime_type, mtime))
|
||||
@ -655,7 +644,7 @@ typedef struct {
|
||||
GtkIconInfo *icon_info;
|
||||
guint width;
|
||||
guint height;
|
||||
GSList *textures;
|
||||
ClutterTexture *texture;
|
||||
} AsyncTextureLoadData;
|
||||
|
||||
static CoglHandle
|
||||
@ -714,31 +703,15 @@ on_pixbuf_loaded (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSList *iter;
|
||||
ShellTextureCache *cache;
|
||||
AsyncTextureLoadData *data;
|
||||
GdkPixbuf *pixbuf;
|
||||
GError *error = NULL;
|
||||
CoglHandle texdata = NULL;
|
||||
CacheKey key;
|
||||
CoglHandle texdata;
|
||||
CacheKey *key;
|
||||
|
||||
data = user_data;
|
||||
cache = SHELL_TEXTURE_CACHE (source);
|
||||
|
||||
memset (&key, 0, sizeof(key));
|
||||
key.policy = data->policy;
|
||||
if (data->icon)
|
||||
key.icon = data->icon;
|
||||
else if (data->recent_info && data->thumbnail)
|
||||
key.thumbnail_uri = (char*)gtk_recent_info_get_uri (data->recent_info);
|
||||
else if (data->thumbnail)
|
||||
key.thumbnail_uri = (char*)data->uri;
|
||||
else if (data->uri)
|
||||
key.uri = data->uri;
|
||||
key.size = data->width;
|
||||
|
||||
g_hash_table_remove (cache->priv->outstanding_requests, &key);
|
||||
|
||||
pixbuf = load_pixbuf_async_finish (cache, result, &error);
|
||||
if (pixbuf == NULL)
|
||||
pixbuf = load_pixbuf_fallback(data);
|
||||
@ -753,24 +726,29 @@ on_pixbuf_loaded (GObject *source,
|
||||
{
|
||||
gpointer orig_key, value;
|
||||
|
||||
if (!g_hash_table_lookup_extended (cache->priv->keyed_cache, &key,
|
||||
key = g_new0 (CacheKey, 1);
|
||||
key->policy = data->policy;
|
||||
if (data->icon)
|
||||
key->icon = g_object_ref (data->icon);
|
||||
else if (data->recent_info && data->thumbnail)
|
||||
key->thumbnail_uri = g_strdup (gtk_recent_info_get_uri (data->recent_info));
|
||||
else if (data->thumbnail)
|
||||
key->thumbnail_uri = g_strdup (data->uri);
|
||||
else if (data->uri)
|
||||
key->uri = g_strdup (data->uri);
|
||||
key->size = data->width;
|
||||
|
||||
if (!g_hash_table_lookup_extended (cache->priv->keyed_cache, key,
|
||||
&orig_key, &value))
|
||||
{
|
||||
cogl_handle_ref (texdata);
|
||||
g_hash_table_insert (cache->priv->keyed_cache, cache_key_dup (&key),
|
||||
texdata);
|
||||
}
|
||||
g_hash_table_insert (cache->priv->keyed_cache, key,
|
||||
texdata);
|
||||
else
|
||||
cache_key_destroy (key);
|
||||
}
|
||||
|
||||
for (iter = data->textures; iter; iter = iter->next)
|
||||
{
|
||||
ClutterTexture *texture = iter->data;
|
||||
set_texture_cogl_texture (texture, texdata);
|
||||
}
|
||||
set_texture_cogl_texture (data->texture, texdata);
|
||||
|
||||
out:
|
||||
if (texdata)
|
||||
cogl_handle_unref (texdata);
|
||||
if (data->icon)
|
||||
{
|
||||
gtk_icon_info_free (data->icon_info);
|
||||
@ -786,11 +764,7 @@ out:
|
||||
|
||||
/* Alternatively we could weakref and just do nothing if the texture
|
||||
is destroyed */
|
||||
for (iter = data->textures; iter; iter = iter->next)
|
||||
{
|
||||
ClutterTexture *texture = iter->data;
|
||||
g_object_unref (texture);
|
||||
}
|
||||
g_object_unref (data->texture);
|
||||
|
||||
g_clear_error (&error);
|
||||
g_free (data);
|
||||
@ -898,59 +872,6 @@ shell_texture_cache_bind_pixbuf_property (ShellTextureCache *cache,
|
||||
return CLUTTER_ACTOR(texture);
|
||||
}
|
||||
|
||||
/**
|
||||
* create_texture_and_ensure_request:
|
||||
* @cache:
|
||||
* @key: A filled in #CacheKey
|
||||
* @request: (out): If no request is outstanding, one will be created and returned here
|
||||
* @texture: (out): A new texture, also added to the request
|
||||
*
|
||||
* Check for any outstanding load for the data represented by @key. If there
|
||||
* is already a request pending, append it to that request to avoid loading
|
||||
* the data multiple times.
|
||||
*
|
||||
* Returns: %TRUE iff there is already a request pending
|
||||
*/
|
||||
static gboolean
|
||||
create_texture_and_ensure_request (ShellTextureCache *cache,
|
||||
CacheKey *key,
|
||||
AsyncTextureLoadData **request,
|
||||
ClutterActor **texture)
|
||||
{
|
||||
CoglHandle texdata;
|
||||
AsyncTextureLoadData *pending;
|
||||
gboolean had_pending;
|
||||
|
||||
*texture = (ClutterActor *) create_default_texture (cache);
|
||||
clutter_actor_set_size (*texture, key->size, key->size);
|
||||
|
||||
texdata = g_hash_table_lookup (cache->priv->keyed_cache, key);
|
||||
|
||||
if (texdata != NULL)
|
||||
{
|
||||
/* We had this cached already, just set the texture and we're done. */
|
||||
set_texture_cogl_texture (CLUTTER_TEXTURE (*texture), texdata);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
pending = g_hash_table_lookup (cache->priv->outstanding_requests, key);
|
||||
had_pending = pending != NULL;
|
||||
|
||||
if (pending == NULL)
|
||||
{
|
||||
/* Not cached and no pending request, create it */
|
||||
*request = g_new0 (AsyncTextureLoadData, 1);
|
||||
g_hash_table_insert (cache->priv->outstanding_requests, cache_key_dup (key), *request);
|
||||
}
|
||||
else
|
||||
*request = pending;
|
||||
|
||||
/* Regardless of whether there was a pending request, prepend our texture here. */
|
||||
(*request)->textures = g_slist_prepend ((*request)->textures, g_object_ref (*texture));
|
||||
|
||||
return had_pending;
|
||||
}
|
||||
|
||||
/**
|
||||
* shell_texture_cache_load_gicon:
|
||||
*
|
||||
@ -964,43 +885,44 @@ shell_texture_cache_load_gicon (ShellTextureCache *cache,
|
||||
GIcon *icon,
|
||||
gint size)
|
||||
{
|
||||
AsyncTextureLoadData *request;
|
||||
ClutterActor *texture;
|
||||
ClutterTexture *texture;
|
||||
CoglHandle texdata;
|
||||
CacheKey key;
|
||||
GtkIconTheme *theme;
|
||||
GtkIconInfo *info;
|
||||
|
||||
texture = create_default_texture (cache);
|
||||
clutter_actor_set_size (CLUTTER_ACTOR (texture), size, size);
|
||||
|
||||
memset (&key, 0, sizeof(key));
|
||||
key.icon = icon;
|
||||
key.size = size;
|
||||
texdata = g_hash_table_lookup (cache->priv->keyed_cache, &key);
|
||||
|
||||
if (create_texture_and_ensure_request (cache, &key, &request, &texture))
|
||||
return texture;
|
||||
|
||||
/* Do theme lookups in the main thread to avoid thread-unsafety */
|
||||
theme = gtk_icon_theme_get_default ();
|
||||
|
||||
info = gtk_icon_theme_lookup_by_gicon (theme, icon, size, GTK_ICON_LOOKUP_USE_BUILTIN);
|
||||
if (info != NULL)
|
||||
if (texdata == NULL)
|
||||
{
|
||||
/* hardcoded here for now; we should actually blow this away on
|
||||
* icon theme changes probably */
|
||||
request->policy = SHELL_TEXTURE_CACHE_POLICY_FOREVER;
|
||||
request->icon = g_object_ref (icon);
|
||||
request->icon_info = info;
|
||||
request->width = request->height = size;
|
||||
GtkIconTheme *theme;
|
||||
GtkIconInfo *info;
|
||||
|
||||
load_icon_pixbuf_async (cache, icon, info, size, NULL, on_pixbuf_loaded, request);
|
||||
/* Do theme lookups in the main thread to avoid thread-unsafety */
|
||||
theme = gtk_icon_theme_get_default ();
|
||||
|
||||
info = gtk_icon_theme_lookup_by_gicon (theme, icon, size, GTK_ICON_LOOKUP_USE_BUILTIN);
|
||||
if (info != NULL)
|
||||
{
|
||||
AsyncTextureLoadData *data;
|
||||
data = g_new0 (AsyncTextureLoadData, 1);
|
||||
/* hardcoded here for now; we should actually blow this away on
|
||||
* icon theme changes probably */
|
||||
data->policy = SHELL_TEXTURE_CACHE_POLICY_FOREVER;
|
||||
data->icon = g_object_ref (icon);
|
||||
data->icon_info = info;
|
||||
data->texture = g_object_ref (texture);
|
||||
data->width = data->height = size;
|
||||
load_icon_pixbuf_async (cache, icon, info, size, NULL, on_pixbuf_loaded, data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Blah; we failed to find the icon, but we've added our texture to the outstanding
|
||||
* requests. In that case, just undo what create_texture_lookup_status did.
|
||||
*/
|
||||
g_slist_foreach (request->textures, (GFunc) g_object_unref, NULL);
|
||||
g_slist_free (request->textures);
|
||||
g_free (request);
|
||||
g_hash_table_remove (cache->priv->outstanding_requests, &key);
|
||||
set_texture_cogl_texture (texture, texdata);
|
||||
}
|
||||
|
||||
return CLUTTER_ACTOR (texture);
|
||||
@ -1061,7 +983,7 @@ shell_texture_cache_load_uri_async (ShellTextureCache *cache,
|
||||
data->uri = g_strdup (uri);
|
||||
data->width = available_width;
|
||||
data->height = available_height;
|
||||
data->textures = g_slist_prepend (data->textures, g_object_ref (texture));
|
||||
data->texture = g_object_ref (texture);
|
||||
load_uri_pixbuf_async (cache, uri, available_width, available_height, NULL, on_pixbuf_loaded, data);
|
||||
|
||||
return CLUTTER_ACTOR (texture);
|
||||
@ -1184,7 +1106,7 @@ shell_texture_cache_load_thumbnail (ShellTextureCache *cache,
|
||||
data->thumbnail = TRUE;
|
||||
data->width = size;
|
||||
data->height = size;
|
||||
data->textures = g_slist_prepend (data->textures, g_object_ref (texture));
|
||||
data->texture = g_object_ref (texture);
|
||||
load_thumbnail_async (cache, uri, mimetype, size, NULL, on_pixbuf_loaded, data);
|
||||
}
|
||||
else
|
||||
@ -1260,7 +1182,7 @@ shell_texture_cache_load_recent_thumbnail (ShellTextureCache *cache,
|
||||
data->recent_info = gtk_recent_info_ref (info);
|
||||
data->width = size;
|
||||
data->height = size;
|
||||
data->textures = g_slist_prepend (data->textures, g_object_ref (texture));
|
||||
data->texture = g_object_ref (texture);
|
||||
load_recent_thumbnail_async (cache, info, size, NULL, on_pixbuf_loaded, data);
|
||||
}
|
||||
else
|
||||
|
@ -1,13 +1,9 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "shell-wm.h"
|
||||
#include "shell-global.h"
|
||||
#include "shell-marshal.h"
|
||||
|
||||
#include <keybindings.h>
|
||||
|
||||
struct _ShellWM {
|
||||
GObject parent;
|
||||
|
||||
@ -31,7 +27,7 @@ enum
|
||||
SWITCH_WORKSPACE,
|
||||
KILL_SWITCH_WORKSPACE,
|
||||
|
||||
KEYBINDING,
|
||||
BEGIN_ALT_TAB,
|
||||
|
||||
LAST_SIGNAL
|
||||
};
|
||||
@ -46,6 +42,7 @@ static guint shell_wm_signals [LAST_SIGNAL] = { 0 };
|
||||
static void
|
||||
shell_wm_init (ShellWM *wm)
|
||||
{
|
||||
meta_alt_tab_handler_register (SHELL_TYPE_ALT_TAB_HANDLER);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -172,32 +169,15 @@ shell_wm_class_init (ShellWMClass *klass)
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
/**
|
||||
* ShellWM::keybinding:
|
||||
* @shellwm: the #ShellWM
|
||||
* @binding: the keybinding name
|
||||
* @window: for window keybindings, the #MetaWindow
|
||||
* @backwards: for "reversible" keybindings, whether or not
|
||||
* the backwards (Shifted) variant was invoked
|
||||
*
|
||||
* Emitted when a keybinding captured via
|
||||
* shell_wm_takeover_keybinding() is invoked. The keybinding name
|
||||
* (which has underscores, not hyphens) is also included as the
|
||||
* detail of the signal name, so you can connect just specific
|
||||
* keybindings.
|
||||
*/
|
||||
shell_wm_signals[KEYBINDING] =
|
||||
g_signal_new ("keybinding",
|
||||
shell_wm_signals[BEGIN_ALT_TAB] =
|
||||
g_signal_new ("begin-alt-tab",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0,
|
||||
NULL, NULL,
|
||||
_shell_marshal_VOID__STRING_OBJECT_BOOLEAN,
|
||||
G_TYPE_NONE, 3,
|
||||
G_TYPE_STRING,
|
||||
META_TYPE_WINDOW,
|
||||
G_TYPE_BOOLEAN);
|
||||
g_cclosure_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE, 1,
|
||||
META_TYPE_ALT_TAB_HANDLER);
|
||||
}
|
||||
|
||||
void
|
||||
@ -411,6 +391,14 @@ _shell_wm_destroy (ShellWM *wm,
|
||||
g_signal_emit (wm, shell_wm_signals[DESTROY], 0, actor);
|
||||
}
|
||||
|
||||
/* Called from shell-alttab.c */
|
||||
void
|
||||
_shell_wm_begin_alt_tab (ShellWM *wm,
|
||||
ShellAltTabHandler *handler)
|
||||
{
|
||||
g_signal_emit (wm, shell_wm_signals[BEGIN_ALT_TAB], 0, handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* shell_wm_new:
|
||||
* @plugin: the #MutterPlugin
|
||||
@ -429,37 +417,3 @@ shell_wm_new (MutterPlugin *plugin)
|
||||
|
||||
return wm;
|
||||
}
|
||||
|
||||
static void
|
||||
shell_wm_key_handler (MetaDisplay *display,
|
||||
MetaScreen *screen,
|
||||
MetaWindow *window,
|
||||
XEvent *event,
|
||||
MetaKeyBinding *binding,
|
||||
gpointer data)
|
||||
{
|
||||
ShellWM *wm = data;
|
||||
gboolean backwards = (event->xkey.state & ShiftMask);
|
||||
|
||||
g_signal_emit (wm, shell_wm_signals[KEYBINDING],
|
||||
g_quark_from_string (binding->name),
|
||||
binding->name, window, backwards);
|
||||
}
|
||||
|
||||
/**
|
||||
* shell_wm_takeover_keybinding:
|
||||
* @wm: the #ShellWM
|
||||
* @binding_name: a mutter keybinding name
|
||||
*
|
||||
* Tells mutter to forward keypresses for @binding_name to the shell
|
||||
* rather than processing them internally. This will cause a
|
||||
* #ShellWM::keybinding signal to be emitted when that key is pressed.
|
||||
*/
|
||||
void
|
||||
shell_wm_takeover_keybinding (ShellWM *wm,
|
||||
const char *binding_name)
|
||||
{
|
||||
meta_keybindings_set_custom_handler (binding_name,
|
||||
shell_wm_key_handler,
|
||||
wm, NULL);
|
||||
}
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include <glib-object.h>
|
||||
#include <mutter-plugin.h>
|
||||
|
||||
#include "shell-alttab.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _ShellWM ShellWM;
|
||||
@ -71,9 +73,10 @@ void _shell_wm_kill_effect (ShellWM *wm,
|
||||
MutterWindow *actor,
|
||||
gulong events);
|
||||
|
||||
/* Keybinding stuff */
|
||||
void shell_wm_takeover_keybinding (ShellWM *wm,
|
||||
const char *binding_name);
|
||||
/* Called by ShellAltTabHandler */
|
||||
|
||||
void _shell_wm_begin_alt_tab (ShellWM *wm,
|
||||
ShellAltTabHandler *handler);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -1,122 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-adjustment.h: Adjustment object
|
||||
*
|
||||
* Copyright 2008 OpenedHand
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Written by: Chris Lord <chris@openedhand.com>, inspired by GtkAdjustment
|
||||
* Port to St by: Robert Staudinger <robsta@openedhand.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(ST_H_INSIDE) && !defined(ST_COMPILATION)
|
||||
#error "Only <st/st.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef __ST_ADJUSTMENT_H__
|
||||
#define __ST_ADJUSTMENT_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define ST_TYPE_ADJUSTMENT (st_adjustment_get_type())
|
||||
#define ST_ADJUSTMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_ADJUSTMENT, StAdjustment))
|
||||
#define ST_IS_ADJUSTMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_ADJUSTMENT))
|
||||
#define ST_ADJUSTMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_ADJUSTMENT, StAdjustmentClass))
|
||||
#define ST_IS_ADJUSTMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_ADJUSTMENT))
|
||||
#define ST_ADJUSTMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_ADJUSTMENT, StAdjustmentClass))
|
||||
|
||||
typedef struct _StAdjustment StAdjustment;
|
||||
typedef struct _StAdjustmentPrivate StAdjustmentPrivate;
|
||||
typedef struct _StAdjustmentClass StAdjustmentClass;
|
||||
|
||||
/**
|
||||
* StAdjustment:
|
||||
*
|
||||
* Class for handling an interval between to values. The contents of
|
||||
* the #StAdjustment are private and should be accessed using the
|
||||
* public API.
|
||||
*/
|
||||
struct _StAdjustment
|
||||
{
|
||||
/*< private >*/
|
||||
GObject parent_instance;
|
||||
|
||||
StAdjustmentPrivate *priv;
|
||||
};
|
||||
|
||||
/**
|
||||
* StAdjustmentClass
|
||||
* @changed: Class handler for the ::changed signal.
|
||||
*
|
||||
* Base class for #StAdjustment.
|
||||
*/
|
||||
struct _StAdjustmentClass
|
||||
{
|
||||
/*< private >*/
|
||||
GObjectClass parent_class;
|
||||
|
||||
/*< public >*/
|
||||
void (* changed) (StAdjustment *adjustment);
|
||||
};
|
||||
|
||||
GType st_adjustment_get_type (void) G_GNUC_CONST;
|
||||
|
||||
StAdjustment *st_adjustment_new (gdouble value,
|
||||
gdouble lower,
|
||||
gdouble upper,
|
||||
gdouble step_increment,
|
||||
gdouble page_increment,
|
||||
gdouble page_size);
|
||||
gdouble st_adjustment_get_value (StAdjustment *adjustment);
|
||||
void st_adjustment_set_value (StAdjustment *adjustment,
|
||||
gdouble value);
|
||||
void st_adjustment_clamp_page (StAdjustment *adjustment,
|
||||
gdouble lower,
|
||||
gdouble upper);
|
||||
void st_adjustment_set_values (StAdjustment *adjustment,
|
||||
gdouble value,
|
||||
gdouble lower,
|
||||
gdouble upper,
|
||||
gdouble step_increment,
|
||||
gdouble page_increment,
|
||||
gdouble page_size);
|
||||
void st_adjustment_get_values (StAdjustment *adjustment,
|
||||
gdouble *value,
|
||||
gdouble *lower,
|
||||
gdouble *upper,
|
||||
gdouble *step_increment,
|
||||
gdouble *page_increment,
|
||||
gdouble *page_size);
|
||||
|
||||
void st_adjustment_interpolate (StAdjustment *adjustment,
|
||||
gdouble value,
|
||||
guint duration);
|
||||
|
||||
gboolean st_adjustment_get_elastic (StAdjustment *adjustment);
|
||||
void st_adjustment_set_elastic (StAdjustment *adjustment,
|
||||
gboolean elastic);
|
||||
|
||||
gboolean st_adjustment_clamp (StAdjustment *adjustment,
|
||||
gboolean interpolate,
|
||||
guint duration);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __ST_ADJUSTMENT_H__ */
|
@ -1,93 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-bin.h: Basic container actor
|
||||
*
|
||||
* Copyright 2009, 2008 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Written by: Emmanuele Bassi <ebassi@linux.intel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(ST_H_INSIDE) && !defined(ST_COMPILATION)
|
||||
#error "Only <st/st.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef __ST_BIN_H__
|
||||
#define __ST_BIN_H__
|
||||
|
||||
#include <st/st-types.h>
|
||||
#include <st/st-widget.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define ST_TYPE_BIN (st_bin_get_type ())
|
||||
#define ST_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_BIN, StBin))
|
||||
#define ST_IS_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_BIN))
|
||||
#define ST_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_BIN, StBinClass))
|
||||
#define ST_IS_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_BIN))
|
||||
#define ST_BIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_BIN, StBinClass))
|
||||
|
||||
typedef struct _StBin StBin;
|
||||
typedef struct _StBinPrivate StBinPrivate;
|
||||
typedef struct _StBinClass StBinClass;
|
||||
|
||||
/**
|
||||
* StBin:
|
||||
*
|
||||
* The #StBin struct contains only private data
|
||||
*/
|
||||
struct _StBin
|
||||
{
|
||||
/*< private >*/
|
||||
StWidget parent_instance;
|
||||
|
||||
StBinPrivate *priv;
|
||||
};
|
||||
|
||||
/**
|
||||
* StBinClass:
|
||||
*
|
||||
* The #StBinClass struct contains only private data
|
||||
*/
|
||||
struct _StBinClass
|
||||
{
|
||||
/*< private >*/
|
||||
StWidgetClass parent_class;
|
||||
};
|
||||
|
||||
GType st_bin_get_type (void) G_GNUC_CONST;
|
||||
|
||||
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);
|
||||
void st_bin_get_fill (StBin *bin,
|
||||
gboolean *x_fill,
|
||||
gboolean *y_fill);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __ST_BIN_H__ */
|
@ -1,92 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "st-border-image.h"
|
||||
|
||||
struct _StBorderImage {
|
||||
GObject parent;
|
||||
|
||||
char *filename;
|
||||
int border_top;
|
||||
int border_right;
|
||||
int border_bottom;
|
||||
int border_left;
|
||||
};
|
||||
|
||||
struct _StBorderImageClass {
|
||||
GObjectClass parent_class;
|
||||
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (StBorderImage, st_border_image, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
st_border_image_finalize (GObject *object)
|
||||
{
|
||||
StBorderImage *image = ST_BORDER_IMAGE (object);
|
||||
|
||||
g_free (image->filename);
|
||||
|
||||
G_OBJECT_CLASS (st_border_image_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
st_border_image_class_init (StBorderImageClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = st_border_image_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
st_border_image_init (StBorderImage *image)
|
||||
{
|
||||
}
|
||||
|
||||
StBorderImage *
|
||||
st_border_image_new (const char *filename,
|
||||
int border_top,
|
||||
int border_right,
|
||||
int border_bottom,
|
||||
int border_left)
|
||||
{
|
||||
StBorderImage *image;
|
||||
|
||||
image = g_object_new (ST_TYPE_BORDER_IMAGE, NULL);
|
||||
|
||||
image->filename = g_strdup (filename);
|
||||
image->border_top = border_top;
|
||||
image->border_right = border_right;
|
||||
image->border_bottom = border_bottom;
|
||||
image->border_left = border_left;
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
const char *
|
||||
st_border_image_get_filename (StBorderImage *image)
|
||||
{
|
||||
g_return_val_if_fail (ST_IS_BORDER_IMAGE (image), NULL);
|
||||
|
||||
return image->filename;
|
||||
}
|
||||
|
||||
void
|
||||
st_border_image_get_borders (StBorderImage *image,
|
||||
int *border_top,
|
||||
int *border_right,
|
||||
int *border_bottom,
|
||||
int *border_left)
|
||||
{
|
||||
g_return_if_fail (ST_IS_BORDER_IMAGE (image));
|
||||
|
||||
if (border_top)
|
||||
*border_top = image->border_top;
|
||||
if (border_right)
|
||||
*border_right = image->border_right;
|
||||
if (border_bottom)
|
||||
*border_bottom = image->border_bottom;
|
||||
if (border_left)
|
||||
*border_left = image->border_left;
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
#ifndef __ST_BORDER_IMAGE_H__
|
||||
#define __ST_BORDER_IMAGE_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* A StBorderImage encapsulates an image with specified unscaled borders on each edge.
|
||||
*/
|
||||
typedef struct _StBorderImage StBorderImage;
|
||||
typedef struct _StBorderImageClass StBorderImageClass;
|
||||
|
||||
#define ST_TYPE_BORDER_IMAGE (st_border_image_get_type ())
|
||||
#define ST_BORDER_IMAGE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), ST_TYPE_BORDER_IMAGE, StBorderImage))
|
||||
#define ST_BORDER_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_BORDER_IMAGE, StBorderImageClass))
|
||||
#define ST_IS_BORDER_IMAGE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), ST_TYPE_BORDER_IMAGE))
|
||||
#define ST_IS_BORDER_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_BORDER_IMAGE))
|
||||
#define ST_BORDER_IMAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_BORDER_IMAGE, StBorderImageClass))
|
||||
|
||||
GType st_border_image_get_type (void) G_GNUC_CONST;
|
||||
|
||||
StBorderImage *st_border_image_new (const char *filename,
|
||||
int border_top,
|
||||
int border_right,
|
||||
int border_bottom,
|
||||
int border_left);
|
||||
|
||||
const char *st_border_image_get_filename (StBorderImage *image);
|
||||
void st_border_image_get_borders (StBorderImage *image,
|
||||
int *border_top,
|
||||
int *border_right,
|
||||
int *border_bottom,
|
||||
int *border_left);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __ST_BORDER_IMAGE_H__ */
|
@ -1,94 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-box-layout.h: box layout actor
|
||||
*
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Written by: Thomas Wood <thomas.wood@intel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(ST_H_INSIDE) && !defined(ST_COMPILATION)
|
||||
#error "Only <st/st.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ST_BOX_LAYOUT_H
|
||||
#define _ST_BOX_LAYOUT_H
|
||||
|
||||
#include <st/st-widget.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define ST_TYPE_BOX_LAYOUT st_box_layout_get_type()
|
||||
|
||||
#define ST_BOX_LAYOUT(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
||||
ST_TYPE_BOX_LAYOUT, StBoxLayout))
|
||||
|
||||
#define ST_BOX_LAYOUT_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), \
|
||||
ST_TYPE_BOX_LAYOUT, StBoxLayoutClass))
|
||||
|
||||
#define ST_IS_BOX_LAYOUT(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
|
||||
ST_TYPE_BOX_LAYOUT))
|
||||
|
||||
#define ST_IS_BOX_LAYOUT_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
|
||||
ST_TYPE_BOX_LAYOUT))
|
||||
|
||||
#define ST_BOX_LAYOUT_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
|
||||
ST_TYPE_BOX_LAYOUT, StBoxLayoutClass))
|
||||
|
||||
typedef struct _StBoxLayout StBoxLayout;
|
||||
typedef struct _StBoxLayoutClass StBoxLayoutClass;
|
||||
typedef struct _StBoxLayoutPrivate StBoxLayoutPrivate;
|
||||
|
||||
/**
|
||||
* StBoxLayout:
|
||||
*
|
||||
* The contents of this structure are private and should only be accessed
|
||||
* through the public API.
|
||||
*/
|
||||
struct _StBoxLayout
|
||||
{
|
||||
/*< private >*/
|
||||
StWidget parent;
|
||||
|
||||
StBoxLayoutPrivate *priv;
|
||||
};
|
||||
|
||||
struct _StBoxLayoutClass
|
||||
{
|
||||
StWidgetClass parent_class;
|
||||
};
|
||||
|
||||
GType st_box_layout_get_type (void);
|
||||
|
||||
StWidget *st_box_layout_new (void);
|
||||
|
||||
void st_box_layout_set_vertical (StBoxLayout *box,
|
||||
gboolean vertical);
|
||||
gboolean st_box_layout_get_vertical (StBoxLayout *box);
|
||||
|
||||
void st_box_layout_set_pack_start (StBoxLayout *box,
|
||||
gboolean pack_start);
|
||||
gboolean st_box_layout_get_pack_start (StBoxLayout *box);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _ST_BOX_LAYOUT_H */
|
@ -1,94 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-button.h: Plain button actor
|
||||
*
|
||||
* Copyright 2007 OpenedHand
|
||||
* Copyright 2008, 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Written by: Emmanuele Bassi <ebassi@openedhand.com>
|
||||
* Thomas Wood <thomas@linux.intel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(ST_H_INSIDE) && !defined(ST_COMPILATION)
|
||||
#error "Only <st/st.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef __ST_BUTTON_H__
|
||||
#define __ST_BUTTON_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#include <st/st-bin.h>
|
||||
|
||||
#define ST_TYPE_BUTTON (st_button_get_type ())
|
||||
#define ST_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_BUTTON, StButton))
|
||||
#define ST_IS_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_BUTTON))
|
||||
#define ST_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_BUTTON, StButtonClass))
|
||||
#define ST_IS_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_BUTTON))
|
||||
#define ST_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_BUTTON, StButtonClass))
|
||||
|
||||
typedef struct _StButton StButton;
|
||||
typedef struct _StButtonPrivate StButtonPrivate;
|
||||
typedef struct _StButtonClass StButtonClass;
|
||||
|
||||
/**
|
||||
* StButton:
|
||||
*
|
||||
* The contents of this structure is private and should only be accessed using
|
||||
* the provided API.
|
||||
*/
|
||||
|
||||
struct _StButton
|
||||
{
|
||||
/*< private >*/
|
||||
StBin parent_instance;
|
||||
|
||||
StButtonPrivate *priv;
|
||||
};
|
||||
|
||||
struct _StButtonClass
|
||||
{
|
||||
StBinClass parent_class;
|
||||
|
||||
/* vfuncs, not signals */
|
||||
void (* pressed) (StButton *button);
|
||||
void (* released) (StButton *button);
|
||||
void (* transition) (StButton *button,
|
||||
ClutterActor *old_bg);
|
||||
|
||||
/* signals */
|
||||
void (* clicked) (StButton *button);
|
||||
};
|
||||
|
||||
GType st_button_get_type (void) G_GNUC_CONST;
|
||||
|
||||
StWidget * st_button_new (void);
|
||||
StWidget * st_button_new_with_label (const gchar *text);
|
||||
G_CONST_RETURN gchar *st_button_get_label (StButton *button);
|
||||
void st_button_set_label (StButton *button,
|
||||
const gchar *text);
|
||||
void st_button_set_toggle_mode (StButton *button,
|
||||
gboolean toggle);
|
||||
gboolean st_button_get_toggle_mode (StButton *button);
|
||||
void st_button_set_checked (StButton *button,
|
||||
gboolean checked);
|
||||
gboolean st_button_get_checked (StButton *button);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __ST_BUTTON_H__ */
|
@ -1,103 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-clipboard.h: clipboard object
|
||||
*
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Written by: Thomas Wood <thomas.wood@intel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(ST_H_INSIDE) && !defined(ST_COMPILATION)
|
||||
#error "Only <st/st.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ST_CLIPBOARD_H
|
||||
#define _ST_CLIPBOARD_H
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define ST_TYPE_CLIPBOARD st_clipboard_get_type()
|
||||
|
||||
#define ST_CLIPBOARD(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
||||
ST_TYPE_CLIPBOARD, StClipboard))
|
||||
|
||||
#define ST_CLIPBOARD_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), \
|
||||
ST_TYPE_CLIPBOARD, StClipboardClass))
|
||||
|
||||
#define ST_IS_CLIPBOARD(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
|
||||
ST_TYPE_CLIPBOARD))
|
||||
|
||||
#define ST_IS_CLIPBOARD_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
|
||||
ST_TYPE_CLIPBOARD))
|
||||
|
||||
#define ST_CLIPBOARD_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
|
||||
ST_TYPE_CLIPBOARD, StClipboardClass))
|
||||
|
||||
typedef struct _StClipboard StClipboard;
|
||||
typedef struct _StClipboardClass StClipboardClass;
|
||||
typedef struct _StClipboardPrivate StClipboardPrivate;
|
||||
|
||||
/**
|
||||
* StClipboard:
|
||||
*
|
||||
* The contents of this structure is private and should only be accessed using
|
||||
* the provided API.
|
||||
*/
|
||||
struct _StClipboard
|
||||
{
|
||||
/*< private >*/
|
||||
GObject parent;
|
||||
StClipboardPrivate *priv;
|
||||
};
|
||||
|
||||
struct _StClipboardClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
/**
|
||||
* StClipboardCallbackFunc:
|
||||
* @clipboard: A #StClipboard
|
||||
* @text: text from the clipboard
|
||||
* @user_data: user data
|
||||
*
|
||||
* Callback function called when text is retrieved from the clipboard.
|
||||
*/
|
||||
typedef void (*StClipboardCallbackFunc) (StClipboard *clipboard,
|
||||
const gchar *text,
|
||||
gpointer user_data);
|
||||
|
||||
GType st_clipboard_get_type (void);
|
||||
|
||||
StClipboard* st_clipboard_get_default (void);
|
||||
|
||||
void st_clipboard_get_text (StClipboard *clipboard,
|
||||
StClipboardCallbackFunc callback,
|
||||
gpointer user_data);
|
||||
void st_clipboard_set_text (StClipboard *clipboard,
|
||||
const gchar *text);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _ST_CLIPBOARD_H */
|
@ -1,89 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-entry.h: Plain entry actor
|
||||
*
|
||||
* Copyright 2008, 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Written by: Thomas Wood <thomas@linux.intel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(ST_H_INSIDE) && !defined(ST_COMPILATION)
|
||||
#error "Only <st/st.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef __ST_ENTRY_H__
|
||||
#define __ST_ENTRY_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#include <st/st-widget.h>
|
||||
|
||||
#define ST_TYPE_ENTRY (st_entry_get_type ())
|
||||
#define ST_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_ENTRY, StEntry))
|
||||
#define ST_IS_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_ENTRY))
|
||||
#define ST_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_ENTRY, StEntryClass))
|
||||
#define ST_IS_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_ENTRY))
|
||||
#define ST_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_ENTRY, StEntryClass))
|
||||
|
||||
typedef struct _StEntry StEntry;
|
||||
typedef struct _StEntryPrivate StEntryPrivate;
|
||||
typedef struct _StEntryClass StEntryClass;
|
||||
|
||||
/**
|
||||
* StEntry:
|
||||
*
|
||||
* The contents of this structure is private and should only be accessed using
|
||||
* the provided API.
|
||||
*/
|
||||
struct _StEntry
|
||||
{
|
||||
/*< private >*/
|
||||
StWidget parent_instance;
|
||||
|
||||
StEntryPrivate *priv;
|
||||
};
|
||||
|
||||
struct _StEntryClass
|
||||
{
|
||||
StWidgetClass parent_class;
|
||||
|
||||
/* signals */
|
||||
void (*primary_icon_clicked) (StEntry *entry);
|
||||
void (*secondary_icon_clicked) (StEntry *entry);
|
||||
};
|
||||
|
||||
GType st_entry_get_type (void) G_GNUC_CONST;
|
||||
|
||||
StWidget * st_entry_new (const gchar *text);
|
||||
G_CONST_RETURN gchar *st_entry_get_text (StEntry *entry);
|
||||
void st_entry_set_text (StEntry *entry,
|
||||
const gchar *text);
|
||||
ClutterActor* st_entry_get_clutter_text (StEntry *entry);
|
||||
|
||||
void st_entry_set_hint_text (StEntry *entry,
|
||||
const gchar *text);
|
||||
G_CONST_RETURN gchar *st_entry_get_hint_text (StEntry *entry);
|
||||
|
||||
void st_entry_set_primary_icon_from_file (StEntry *entry,
|
||||
const gchar *filename);
|
||||
void st_entry_set_secondary_icon_from_file (StEntry *entry,
|
||||
const gchar *filename);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __ST_ENTRY_H__ */
|
@ -1,342 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-label.c: Plain label actor
|
||||
*
|
||||
* Copyright 2008,2009 Intel Corporation
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Written by: Thomas Wood <thomas@linux.intel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:st-label
|
||||
* @short_description: Widget for displaying text
|
||||
*
|
||||
* #StLabel is a simple widget for displaying text. It derives from
|
||||
* #StWidget to add extra style and placement functionality over
|
||||
* #ClutterText. The internal #ClutterText is publicly accessibly to allow
|
||||
* applications to set further properties.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
#include "st-label.h"
|
||||
|
||||
#include "st-widget.h"
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
||||
PROP_CLUTTER_TEXT,
|
||||
PROP_TEXT
|
||||
};
|
||||
|
||||
#define ST_LABEL_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ST_TYPE_LABEL, StLabelPrivate))
|
||||
|
||||
struct _StLabelPrivate
|
||||
{
|
||||
ClutterActor *label;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (StLabel, st_label, ST_TYPE_WIDGET);
|
||||
|
||||
static void
|
||||
st_label_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StLabel *label = ST_LABEL (gobject);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_TEXT:
|
||||
st_label_set_text (label, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
st_label_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StLabelPrivate *priv = ST_LABEL (gobject)->priv;
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_CLUTTER_TEXT:
|
||||
g_value_set_object (value, priv->label);
|
||||
break;
|
||||
|
||||
case PROP_TEXT:
|
||||
g_value_set_string (value, clutter_text_get_text (CLUTTER_TEXT (priv->label)));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
st_label_style_changed (StWidget *self)
|
||||
{
|
||||
StLabelPrivate *priv;
|
||||
StThemeNode *theme_node;
|
||||
ClutterColor color;
|
||||
const PangoFontDescription *font;
|
||||
gchar *font_string;
|
||||
|
||||
priv = ST_LABEL (self)->priv;
|
||||
theme_node = st_widget_get_theme_node (self);
|
||||
st_theme_node_get_foreground_color (theme_node, &color);
|
||||
clutter_text_set_color (CLUTTER_TEXT (priv->label), &color);
|
||||
|
||||
font = st_theme_node_get_font (theme_node);
|
||||
font_string = pango_font_description_to_string (font);
|
||||
clutter_text_set_font_name (CLUTTER_TEXT (priv->label), font_string);
|
||||
g_free (font_string);
|
||||
|
||||
ST_WIDGET_CLASS (st_label_parent_class)->style_changed (self);
|
||||
}
|
||||
|
||||
static void
|
||||
st_label_get_preferred_width (ClutterActor *actor,
|
||||
gfloat for_height,
|
||||
gfloat *min_width_p,
|
||||
gfloat *natural_width_p)
|
||||
{
|
||||
StLabelPrivate *priv = ST_LABEL (actor)->priv;
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
||||
|
||||
st_theme_node_adjust_for_height (theme_node, &for_height);
|
||||
|
||||
clutter_actor_get_preferred_width (priv->label, for_height,
|
||||
min_width_p,
|
||||
natural_width_p);
|
||||
|
||||
st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p);
|
||||
}
|
||||
|
||||
static void
|
||||
st_label_get_preferred_height (ClutterActor *actor,
|
||||
gfloat for_width,
|
||||
gfloat *min_height_p,
|
||||
gfloat *natural_height_p)
|
||||
{
|
||||
StLabelPrivate *priv = ST_LABEL (actor)->priv;
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
||||
|
||||
st_theme_node_adjust_for_width (theme_node, &for_width);
|
||||
|
||||
clutter_actor_get_preferred_height (priv->label, for_width,
|
||||
min_height_p,
|
||||
natural_height_p);
|
||||
|
||||
st_theme_node_adjust_preferred_height (theme_node, min_height_p, natural_height_p);
|
||||
}
|
||||
|
||||
static void
|
||||
st_label_allocate (ClutterActor *actor,
|
||||
const ClutterActorBox *box,
|
||||
ClutterAllocationFlags flags)
|
||||
{
|
||||
StLabelPrivate *priv = ST_LABEL (actor)->priv;
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
||||
ClutterActorClass *parent_class;
|
||||
ClutterActorBox content_box;
|
||||
|
||||
st_theme_node_get_content_box (theme_node, box, &content_box);
|
||||
|
||||
parent_class = CLUTTER_ACTOR_CLASS (st_label_parent_class);
|
||||
parent_class->allocate (actor, box, flags);
|
||||
|
||||
clutter_actor_allocate (priv->label, &content_box, flags);
|
||||
}
|
||||
|
||||
static void
|
||||
st_label_paint (ClutterActor *actor)
|
||||
{
|
||||
StLabelPrivate *priv = ST_LABEL (actor)->priv;
|
||||
ClutterActorClass *parent_class;
|
||||
|
||||
parent_class = CLUTTER_ACTOR_CLASS (st_label_parent_class);
|
||||
parent_class->paint (actor);
|
||||
|
||||
clutter_actor_paint (priv->label);
|
||||
}
|
||||
|
||||
static void
|
||||
st_label_map (ClutterActor *actor)
|
||||
{
|
||||
StLabelPrivate *priv = ST_LABEL (actor)->priv;
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_label_parent_class)->map (actor);
|
||||
|
||||
clutter_actor_map (priv->label);
|
||||
}
|
||||
|
||||
static void
|
||||
st_label_unmap (ClutterActor *actor)
|
||||
{
|
||||
StLabelPrivate *priv = ST_LABEL (actor)->priv;
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_label_parent_class)->unmap (actor);
|
||||
|
||||
clutter_actor_unmap (priv->label);
|
||||
}
|
||||
|
||||
static void
|
||||
st_label_class_init (StLabelClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
||||
StWidgetClass *widget_class = ST_WIDGET_CLASS (klass);
|
||||
GParamSpec *pspec;
|
||||
|
||||
g_type_class_add_private (klass, sizeof (StLabelPrivate));
|
||||
|
||||
gobject_class->set_property = st_label_set_property;
|
||||
gobject_class->get_property = st_label_get_property;
|
||||
|
||||
actor_class->paint = st_label_paint;
|
||||
actor_class->allocate = st_label_allocate;
|
||||
actor_class->get_preferred_width = st_label_get_preferred_width;
|
||||
actor_class->get_preferred_height = st_label_get_preferred_height;
|
||||
actor_class->map = st_label_map;
|
||||
actor_class->unmap = st_label_unmap;
|
||||
|
||||
widget_class->style_changed = st_label_style_changed;
|
||||
|
||||
pspec = g_param_spec_object ("clutter-text",
|
||||
"Clutter Text",
|
||||
"Internal ClutterText actor",
|
||||
CLUTTER_TYPE_TEXT,
|
||||
G_PARAM_READABLE);
|
||||
g_object_class_install_property (gobject_class, PROP_CLUTTER_TEXT, pspec);
|
||||
|
||||
pspec = g_param_spec_string ("text",
|
||||
"Text",
|
||||
"Text of the label",
|
||||
NULL, G_PARAM_READWRITE);
|
||||
g_object_class_install_property (gobject_class, PROP_TEXT, pspec);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
st_label_init (StLabel *label)
|
||||
{
|
||||
StLabelPrivate *priv;
|
||||
|
||||
label->priv = priv = ST_LABEL_GET_PRIVATE (label);
|
||||
|
||||
label->priv->label = g_object_new (CLUTTER_TYPE_TEXT,
|
||||
"ellipsize", PANGO_ELLIPSIZE_END,
|
||||
NULL);
|
||||
|
||||
clutter_actor_set_parent (priv->label, CLUTTER_ACTOR (label));
|
||||
}
|
||||
|
||||
/**
|
||||
* st_label_new:
|
||||
* @text: text to set the label to
|
||||
*
|
||||
* Create a new #StLabel with the specified label
|
||||
*
|
||||
* Returns: a new #StLabel
|
||||
*/
|
||||
StWidget *
|
||||
st_label_new (const gchar *text)
|
||||
{
|
||||
if (text == NULL || *text == '\0')
|
||||
return g_object_new (ST_TYPE_LABEL, NULL);
|
||||
else
|
||||
return g_object_new (ST_TYPE_LABEL,
|
||||
"text", text,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_label_get_text:
|
||||
* @label: a #StLabel
|
||||
*
|
||||
* Get the text displayed on the label
|
||||
*
|
||||
* Returns: the text for the label. This must not be freed by the application
|
||||
*/
|
||||
G_CONST_RETURN gchar *
|
||||
st_label_get_text (StLabel *label)
|
||||
{
|
||||
g_return_val_if_fail (ST_IS_LABEL (label), NULL);
|
||||
|
||||
return clutter_text_get_text (CLUTTER_TEXT (label->priv->label));
|
||||
}
|
||||
|
||||
/**
|
||||
* st_label_set_text:
|
||||
* @label: a #StLabel
|
||||
* @text: text to set the label to
|
||||
*
|
||||
* Sets the text displayed on the label
|
||||
*/
|
||||
void
|
||||
st_label_set_text (StLabel *label,
|
||||
const gchar *text)
|
||||
{
|
||||
StLabelPrivate *priv;
|
||||
|
||||
g_return_if_fail (ST_IS_LABEL (label));
|
||||
g_return_if_fail (text != NULL);
|
||||
|
||||
priv = label->priv;
|
||||
|
||||
clutter_text_set_text (CLUTTER_TEXT (priv->label), text);
|
||||
|
||||
g_object_notify (G_OBJECT (label), "text");
|
||||
}
|
||||
|
||||
/**
|
||||
* st_label_get_clutter_text:
|
||||
* @label: a #StLabel
|
||||
*
|
||||
* Retrieve the internal #ClutterText so that extra parameters can be set
|
||||
*
|
||||
* Returns: (transfer none): ethe #ClutterText used by #StLabel. The label
|
||||
* is owned by the #StLabel and should not be unref'ed by the application.
|
||||
*/
|
||||
ClutterActor*
|
||||
st_label_get_clutter_text (StLabel *label)
|
||||
{
|
||||
g_return_val_if_fail (ST_LABEL (label), NULL);
|
||||
|
||||
return label->priv->label;
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-label.h: Plain label actor
|
||||
*
|
||||
* Copyright 2008, 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Written by: Thomas Wood <thomas@linux.intel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(ST_H_INSIDE) && !defined(ST_COMPILATION)
|
||||
#error "Only <st/st.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef __ST_LABEL_H__
|
||||
#define __ST_LABEL_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#include <st/st-widget.h>
|
||||
|
||||
#define ST_TYPE_LABEL (st_label_get_type ())
|
||||
#define ST_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_LABEL, StLabel))
|
||||
#define ST_IS_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_LABEL))
|
||||
#define ST_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_LABEL, StLabelClass))
|
||||
#define ST_IS_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_LABEL))
|
||||
#define ST_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_LABEL, StLabelClass))
|
||||
|
||||
typedef struct _StLabel StLabel;
|
||||
typedef struct _StLabelPrivate StLabelPrivate;
|
||||
typedef struct _StLabelClass StLabelClass;
|
||||
|
||||
/**
|
||||
* StLabel:
|
||||
*
|
||||
* The contents of this structure is private and should only be accessed using
|
||||
* the provided API.
|
||||
*/
|
||||
struct _StLabel
|
||||
{
|
||||
/*< private >*/
|
||||
StWidget parent_instance;
|
||||
|
||||
StLabelPrivate *priv;
|
||||
};
|
||||
|
||||
struct _StLabelClass
|
||||
{
|
||||
StWidgetClass parent_class;
|
||||
};
|
||||
|
||||
GType st_label_get_type (void) G_GNUC_CONST;
|
||||
|
||||
StWidget * st_label_new (const gchar *text);
|
||||
G_CONST_RETURN gchar *st_label_get_text (StLabel *label);
|
||||
void st_label_set_text (StLabel *label,
|
||||
const gchar *text);
|
||||
ClutterActor * st_label_get_clutter_text (StLabel *label);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __ST_LABEL_H__ */
|
@ -1,83 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-scroll-bar.h: Scroll bar actor
|
||||
*
|
||||
* Copyright 2008 OpenedHand
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Written by: Chris Lord <chris@openedhand.com>
|
||||
* Port to St by: Robert Staudinger <robsta@openedhand.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(ST_H_INSIDE) && !defined(ST_COMPILATION)
|
||||
#error "Only <st/st.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef __ST_SCROLL_BAR_H__
|
||||
#define __ST_SCROLL_BAR_H__
|
||||
|
||||
#include <st/st-adjustment.h>
|
||||
#include <st/st-bin.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define ST_TYPE_SCROLL_BAR (st_scroll_bar_get_type())
|
||||
#define ST_SCROLL_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_SCROLL_BAR, StScrollBar))
|
||||
#define ST_IS_SCROLL_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_SCROLL_BAR))
|
||||
#define ST_SCROLL_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_SCROLL_BAR, StScrollBarClass))
|
||||
#define ST_IS_SCROLL_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_SCROLL_BAR))
|
||||
#define ST_SCROLL_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_SCROLL_BAR, StScrollBarClass))
|
||||
|
||||
typedef struct _StScrollBar StScrollBar;
|
||||
typedef struct _StScrollBarPrivate StScrollBarPrivate;
|
||||
typedef struct _StScrollBarClass StScrollBarClass;
|
||||
|
||||
/**
|
||||
* StScrollBar:
|
||||
*
|
||||
* The contents of this structure are private and should only be accessed
|
||||
* through the public API.
|
||||
*/
|
||||
struct _StScrollBar
|
||||
{
|
||||
/*< private >*/
|
||||
StBin parent_instance;
|
||||
|
||||
StScrollBarPrivate *priv;
|
||||
};
|
||||
|
||||
struct _StScrollBarClass
|
||||
{
|
||||
StBinClass parent_class;
|
||||
|
||||
/* signals */
|
||||
void (*scroll_start) (StScrollBar *bar);
|
||||
void (*scroll_stop) (StScrollBar *bar);
|
||||
};
|
||||
|
||||
GType st_scroll_bar_get_type (void) G_GNUC_CONST;
|
||||
|
||||
StWidget *st_scroll_bar_new (StAdjustment *adjustment);
|
||||
|
||||
void st_scroll_bar_set_adjustment (StScrollBar *bar,
|
||||
StAdjustment *adjustment);
|
||||
StAdjustment *st_scroll_bar_get_adjustment (StScrollBar *bar);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __ST_SCROLL_BAR_H__ */
|
@ -1,844 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-scroll-view.h: Container with scroll-bars
|
||||
*
|
||||
* Copyright 2008 OpenedHand
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Written by: Chris Lord <chris@openedhand.com>
|
||||
* Port to St by: Robert Staudinger <robsta@openedhand.com>
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:st-scroll-view
|
||||
* @short_description: a container for scrollable children
|
||||
*
|
||||
* #StScrollView is a single child container for actors that implement
|
||||
* #StScrollable. It provides scrollbars around the edge of the child to
|
||||
* allow the user to move around the scrollable area.
|
||||
*/
|
||||
|
||||
#include "st-scroll-view.h"
|
||||
#include "st-marshal.h"
|
||||
#include "st-scroll-bar.h"
|
||||
#include "st-scrollable.h"
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
static void clutter_container_iface_init (ClutterContainerIface *iface);
|
||||
|
||||
static ClutterContainerIface *st_scroll_view_parent_iface = NULL;
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (StScrollView, st_scroll_view, ST_TYPE_BIN,
|
||||
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_CONTAINER,
|
||||
clutter_container_iface_init))
|
||||
|
||||
#define SCROLL_VIEW_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
|
||||
ST_TYPE_SCROLL_VIEW, \
|
||||
StScrollViewPrivate))
|
||||
|
||||
/* Default width (or height - the narrow dimension) for the scrollbars*/
|
||||
#define DEFAULT_SCROLLBAR_WIDTH 24
|
||||
|
||||
struct _StScrollViewPrivate
|
||||
{
|
||||
/* a pointer to the child; this is actually stored
|
||||
* inside StBin:child, but we keep it to avoid
|
||||
* calling st_bin_get_child() every time we need it
|
||||
*/
|
||||
ClutterActor *child;
|
||||
|
||||
ClutterActor *hscroll;
|
||||
ClutterActor *vscroll;
|
||||
|
||||
gfloat row_size;
|
||||
gfloat column_size;
|
||||
|
||||
gboolean row_size_set : 1;
|
||||
gboolean column_size_set : 1;
|
||||
guint mouse_scroll : 1;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
|
||||
PROP_HSCROLL,
|
||||
PROP_VSCROLL,
|
||||
PROP_MOUSE_SCROLL
|
||||
};
|
||||
|
||||
static void
|
||||
st_scroll_view_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StScrollViewPrivate *priv = ((StScrollView *) object)->priv;
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_HSCROLL:
|
||||
g_value_set_object (value, priv->hscroll);
|
||||
break;
|
||||
case PROP_VSCROLL:
|
||||
g_value_set_object (value, priv->vscroll);
|
||||
break;
|
||||
case PROP_MOUSE_SCROLL:
|
||||
g_value_set_boolean (value, priv->mouse_scroll);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_view_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_MOUSE_SCROLL:
|
||||
st_scroll_view_set_mouse_scrolling ((StScrollView *) object,
|
||||
g_value_get_boolean (value));
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_view_dispose (GObject *object)
|
||||
{
|
||||
StScrollViewPrivate *priv = ST_SCROLL_VIEW (object)->priv;
|
||||
|
||||
priv->child = NULL;
|
||||
|
||||
if (priv->vscroll)
|
||||
{
|
||||
clutter_actor_unparent (priv->vscroll);
|
||||
priv->vscroll = NULL;
|
||||
}
|
||||
|
||||
if (priv->hscroll)
|
||||
{
|
||||
clutter_actor_unparent (priv->hscroll);
|
||||
priv->hscroll = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (st_scroll_view_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_view_finalize (GObject *object)
|
||||
{
|
||||
G_OBJECT_CLASS (st_scroll_view_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_view_paint (ClutterActor *actor)
|
||||
{
|
||||
StScrollViewPrivate *priv = ST_SCROLL_VIEW (actor)->priv;
|
||||
|
||||
/* StBin will paint the child */
|
||||
CLUTTER_ACTOR_CLASS (st_scroll_view_parent_class)->paint (actor);
|
||||
|
||||
/* paint our custom children */
|
||||
if (CLUTTER_ACTOR_IS_VISIBLE (priv->hscroll))
|
||||
clutter_actor_paint (priv->hscroll);
|
||||
if (CLUTTER_ACTOR_IS_VISIBLE (priv->vscroll))
|
||||
clutter_actor_paint (priv->vscroll);
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_view_pick (ClutterActor *actor,
|
||||
const ClutterColor *color)
|
||||
{
|
||||
StScrollViewPrivate *priv = ST_SCROLL_VIEW (actor)->priv;
|
||||
|
||||
/* Chain up so we get a bounding box pained (if we are reactive) */
|
||||
CLUTTER_ACTOR_CLASS (st_scroll_view_parent_class)->pick (actor, color);
|
||||
|
||||
/* paint our custom children */
|
||||
if (CLUTTER_ACTOR_IS_VISIBLE (priv->hscroll))
|
||||
clutter_actor_paint (priv->hscroll);
|
||||
if (CLUTTER_ACTOR_IS_VISIBLE (priv->vscroll))
|
||||
clutter_actor_paint (priv->vscroll);
|
||||
}
|
||||
|
||||
static double
|
||||
get_scrollbar_width (StScrollView *scroll_view)
|
||||
{
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (scroll_view));
|
||||
double result = DEFAULT_SCROLLBAR_WIDTH;
|
||||
|
||||
st_theme_node_get_length (theme_node, "scrollbar-width", FALSE, &result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static double
|
||||
get_scrollbar_height (StScrollView *scroll_view)
|
||||
{
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (scroll_view));
|
||||
double result = DEFAULT_SCROLLBAR_WIDTH;
|
||||
|
||||
st_theme_node_get_length (theme_node, "scrollbar-height", FALSE, &result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_view_get_preferred_width (ClutterActor *actor,
|
||||
gfloat for_height,
|
||||
gfloat *min_width_p,
|
||||
gfloat *natural_width_p)
|
||||
{
|
||||
StScrollViewPrivate *priv = ST_SCROLL_VIEW (actor)->priv;
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
||||
|
||||
if (!priv->child)
|
||||
return;
|
||||
|
||||
st_theme_node_adjust_for_height (theme_node, &for_height);
|
||||
|
||||
/* Our natural width is the natural width of the child */
|
||||
clutter_actor_get_preferred_width (priv->child,
|
||||
for_height,
|
||||
NULL,
|
||||
natural_width_p);
|
||||
|
||||
/* Add space for the scroll-bar if we can determine it will be necessary */
|
||||
if ((for_height >= 0) && natural_width_p)
|
||||
{
|
||||
gfloat natural_height;
|
||||
|
||||
clutter_actor_get_preferred_height (priv->child, -1.0,
|
||||
NULL,
|
||||
&natural_height);
|
||||
if (for_height < natural_height)
|
||||
*natural_width_p += get_scrollbar_width (ST_SCROLL_VIEW (actor));
|
||||
}
|
||||
|
||||
if (min_width_p)
|
||||
*min_width_p = 0;
|
||||
|
||||
st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p);
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_view_get_preferred_height (ClutterActor *actor,
|
||||
gfloat for_width,
|
||||
gfloat *min_height_p,
|
||||
gfloat *natural_height_p)
|
||||
{
|
||||
StScrollViewPrivate *priv = ST_SCROLL_VIEW (actor)->priv;
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
||||
|
||||
if (!priv->child)
|
||||
return;
|
||||
|
||||
st_theme_node_adjust_for_width (theme_node, &for_width);
|
||||
|
||||
/* Our natural height is the natural height of the child */
|
||||
clutter_actor_get_preferred_height (priv->child,
|
||||
for_width,
|
||||
NULL,
|
||||
natural_height_p);
|
||||
|
||||
/* Add space for the scroll-bar if we can determine it will be necessary */
|
||||
if ((for_width >= 0) && natural_height_p)
|
||||
{
|
||||
gfloat natural_width;
|
||||
|
||||
clutter_actor_get_preferred_width (priv->child, -1.0,
|
||||
NULL,
|
||||
&natural_width);
|
||||
if (for_width < natural_width)
|
||||
*natural_height_p += get_scrollbar_height (ST_SCROLL_VIEW (actor));
|
||||
}
|
||||
|
||||
if (min_height_p)
|
||||
*min_height_p = 0;
|
||||
|
||||
st_theme_node_adjust_preferred_height (theme_node, min_height_p, natural_height_p);
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_view_allocate (ClutterActor *actor,
|
||||
const ClutterActorBox *box,
|
||||
ClutterAllocationFlags flags)
|
||||
{
|
||||
ClutterActorBox content_box, child_box;
|
||||
ClutterActorClass *parent_parent_class;
|
||||
gfloat avail_width, avail_height, sb_width, sb_height;
|
||||
|
||||
StScrollViewPrivate *priv = ST_SCROLL_VIEW (actor)->priv;
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
||||
|
||||
/* Chain up to the parent's parent class
|
||||
*
|
||||
* We do this because we do not want StBin to allocate the child, as we
|
||||
* give it a different allocation later, depending on whether the scrollbars
|
||||
* are visible
|
||||
*/
|
||||
parent_parent_class
|
||||
= g_type_class_peek_parent (st_scroll_view_parent_class);
|
||||
|
||||
CLUTTER_ACTOR_CLASS (parent_parent_class)->
|
||||
allocate (actor, box, flags);
|
||||
|
||||
|
||||
st_theme_node_get_content_box (theme_node, box, &content_box);
|
||||
|
||||
avail_width = content_box.x2 - content_box.x1;
|
||||
avail_height = content_box.y2 - content_box.y1;
|
||||
|
||||
sb_width = get_scrollbar_width (ST_SCROLL_VIEW (actor));
|
||||
sb_height = get_scrollbar_width (ST_SCROLL_VIEW (actor));
|
||||
|
||||
if (!CLUTTER_ACTOR_IS_VISIBLE (priv->vscroll))
|
||||
sb_width = 0;
|
||||
|
||||
if (!CLUTTER_ACTOR_IS_VISIBLE (priv->hscroll))
|
||||
sb_height = 0;
|
||||
|
||||
/* Vertical scrollbar */
|
||||
if (CLUTTER_ACTOR_IS_VISIBLE (priv->vscroll))
|
||||
{
|
||||
child_box.x1 = content_box.x2 - sb_width;
|
||||
child_box.y1 = content_box.y1;
|
||||
child_box.x2 = content_box.x2;
|
||||
child_box.y2 = content_box.y2 - sb_height;
|
||||
|
||||
clutter_actor_allocate (priv->vscroll, &child_box, flags);
|
||||
}
|
||||
|
||||
/* Horizontal scrollbar */
|
||||
if (CLUTTER_ACTOR_IS_VISIBLE (priv->hscroll))
|
||||
{
|
||||
child_box.x1 = content_box.x1;
|
||||
child_box.y1 = content_box.y2 - sb_height;
|
||||
child_box.x2 = content_box.x2 - sb_width;
|
||||
child_box.y2 = content_box.y2;
|
||||
|
||||
clutter_actor_allocate (priv->hscroll, &child_box, flags);
|
||||
}
|
||||
|
||||
|
||||
/* Child */
|
||||
child_box.x1 = content_box.x1;
|
||||
child_box.y1 = content_box.y1;
|
||||
child_box.x2 = content_box.x2 - sb_width;
|
||||
child_box.y2 = content_box.y2 - sb_height;
|
||||
|
||||
if (priv->child)
|
||||
clutter_actor_allocate (priv->child, &child_box, flags);
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_view_style_changed (StWidget *widget)
|
||||
{
|
||||
StScrollViewPrivate *priv = ST_SCROLL_VIEW (widget)->priv;
|
||||
|
||||
st_widget_style_changed (ST_WIDGET (priv->hscroll));
|
||||
st_widget_style_changed (ST_WIDGET (priv->vscroll));
|
||||
|
||||
ST_WIDGET_CLASS (st_scroll_view_parent_class)->style_changed (widget);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
st_scroll_view_scroll_event (ClutterActor *self,
|
||||
ClutterScrollEvent *event)
|
||||
{
|
||||
StScrollViewPrivate *priv = ST_SCROLL_VIEW (self)->priv;
|
||||
gdouble lower, value, upper, step;
|
||||
StAdjustment *vadjustment, *hadjustment;
|
||||
|
||||
/* don't handle scroll events if requested not to */
|
||||
if (!priv->mouse_scroll)
|
||||
return FALSE;
|
||||
|
||||
hadjustment = st_scroll_bar_get_adjustment (ST_SCROLL_BAR(priv->hscroll));
|
||||
vadjustment = st_scroll_bar_get_adjustment (ST_SCROLL_BAR(priv->vscroll));
|
||||
|
||||
switch (event->direction)
|
||||
{
|
||||
case CLUTTER_SCROLL_UP:
|
||||
case CLUTTER_SCROLL_DOWN:
|
||||
if (vadjustment)
|
||||
g_object_get (vadjustment,
|
||||
"lower", &lower,
|
||||
"step-increment", &step,
|
||||
"value", &value,
|
||||
"upper", &upper,
|
||||
NULL);
|
||||
else
|
||||
return FALSE;
|
||||
break;
|
||||
case CLUTTER_SCROLL_LEFT:
|
||||
case CLUTTER_SCROLL_RIGHT:
|
||||
if (vadjustment)
|
||||
g_object_get (hadjustment,
|
||||
"lower", &lower,
|
||||
"step-increment", &step,
|
||||
"value", &value,
|
||||
"upper", &upper,
|
||||
NULL);
|
||||
else
|
||||
return FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (event->direction)
|
||||
{
|
||||
case CLUTTER_SCROLL_UP:
|
||||
if (value == lower)
|
||||
return FALSE;
|
||||
else
|
||||
st_adjustment_set_value (vadjustment, value - step);
|
||||
break;
|
||||
case CLUTTER_SCROLL_DOWN:
|
||||
if (value == upper)
|
||||
return FALSE;
|
||||
else
|
||||
st_adjustment_set_value (vadjustment, value + step);
|
||||
break;
|
||||
case CLUTTER_SCROLL_LEFT:
|
||||
if (value == lower)
|
||||
return FALSE;
|
||||
else
|
||||
st_adjustment_set_value (hadjustment, value - step);
|
||||
break;
|
||||
case CLUTTER_SCROLL_RIGHT:
|
||||
if (value == upper)
|
||||
return FALSE;
|
||||
else
|
||||
st_adjustment_set_value (hadjustment, value + step);
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_view_class_init (StScrollViewClass *klass)
|
||||
{
|
||||
GParamSpec *pspec;
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
||||
StWidgetClass *widget_class = ST_WIDGET_CLASS (klass);
|
||||
|
||||
g_type_class_add_private (klass, sizeof (StScrollViewPrivate));
|
||||
|
||||
object_class->get_property = st_scroll_view_get_property;
|
||||
object_class->set_property = st_scroll_view_set_property;
|
||||
object_class->dispose= st_scroll_view_dispose;
|
||||
object_class->finalize = st_scroll_view_finalize;
|
||||
|
||||
actor_class->paint = st_scroll_view_paint;
|
||||
actor_class->pick = st_scroll_view_pick;
|
||||
actor_class->get_preferred_width = st_scroll_view_get_preferred_width;
|
||||
actor_class->get_preferred_height = st_scroll_view_get_preferred_height;
|
||||
actor_class->allocate = st_scroll_view_allocate;
|
||||
actor_class->scroll_event = st_scroll_view_scroll_event;
|
||||
|
||||
widget_class->style_changed = st_scroll_view_style_changed;
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_HSCROLL,
|
||||
g_param_spec_object ("hscroll",
|
||||
"StScrollBar",
|
||||
"Horizontal scroll indicator",
|
||||
ST_TYPE_SCROLL_BAR,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_VSCROLL,
|
||||
g_param_spec_object ("vscroll",
|
||||
"StScrollBar",
|
||||
"Vertical scroll indicator",
|
||||
ST_TYPE_SCROLL_BAR,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
pspec = g_param_spec_boolean ("enable-mouse-scrolling",
|
||||
"Enable Mouse Scrolling",
|
||||
"Enable automatic mouse wheel scrolling",
|
||||
TRUE,
|
||||
G_PARAM_READWRITE);
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_MOUSE_SCROLL,
|
||||
pspec);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
child_adjustment_changed_cb (StAdjustment *adjustment,
|
||||
ClutterActor *bar)
|
||||
{
|
||||
StScrollView *scroll;
|
||||
gdouble lower, upper, page_size;
|
||||
|
||||
scroll = ST_SCROLL_VIEW (clutter_actor_get_parent (bar));
|
||||
|
||||
/* Determine if this scroll-bar should be visible */
|
||||
st_adjustment_get_values (adjustment, NULL,
|
||||
&lower, &upper,
|
||||
NULL, NULL,
|
||||
&page_size);
|
||||
|
||||
if ((upper - lower) > page_size)
|
||||
clutter_actor_show (bar);
|
||||
else
|
||||
clutter_actor_hide (bar);
|
||||
|
||||
/* Request a resize */
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (scroll));
|
||||
}
|
||||
|
||||
static void
|
||||
child_hadjustment_notify_cb (GObject *gobject,
|
||||
GParamSpec *arg1,
|
||||
gpointer user_data)
|
||||
{
|
||||
StAdjustment *hadjust;
|
||||
|
||||
ClutterActor *actor = CLUTTER_ACTOR (gobject);
|
||||
StScrollViewPrivate *priv = ST_SCROLL_VIEW (user_data)->priv;
|
||||
|
||||
hadjust = st_scroll_bar_get_adjustment (ST_SCROLL_BAR(priv->hscroll));
|
||||
if (hadjust)
|
||||
g_signal_handlers_disconnect_by_func (hadjust,
|
||||
child_adjustment_changed_cb,
|
||||
priv->hscroll);
|
||||
|
||||
st_scrollable_get_adjustments (ST_SCROLLABLE (actor), &hadjust, NULL);
|
||||
if (hadjust)
|
||||
{
|
||||
/* Force scroll step if neede. */
|
||||
if (priv->column_size_set)
|
||||
{
|
||||
g_object_set (hadjust,
|
||||
"step-increment", priv->column_size,
|
||||
NULL);
|
||||
}
|
||||
|
||||
st_scroll_bar_set_adjustment (ST_SCROLL_BAR(priv->hscroll), hadjust);
|
||||
g_signal_connect (hadjust, "changed", G_CALLBACK (
|
||||
child_adjustment_changed_cb), priv->hscroll);
|
||||
child_adjustment_changed_cb (hadjust, priv->hscroll);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
child_vadjustment_notify_cb (GObject *gobject,
|
||||
GParamSpec *arg1,
|
||||
gpointer user_data)
|
||||
{
|
||||
StAdjustment *vadjust;
|
||||
|
||||
ClutterActor *actor = CLUTTER_ACTOR (gobject);
|
||||
StScrollViewPrivate *priv = ST_SCROLL_VIEW (user_data)->priv;
|
||||
|
||||
vadjust = st_scroll_bar_get_adjustment (ST_SCROLL_BAR(priv->vscroll));
|
||||
if (vadjust)
|
||||
g_signal_handlers_disconnect_by_func (vadjust,
|
||||
child_adjustment_changed_cb,
|
||||
priv->vscroll);
|
||||
|
||||
st_scrollable_get_adjustments (ST_SCROLLABLE(actor), NULL, &vadjust);
|
||||
if (vadjust)
|
||||
{
|
||||
/* Force scroll step if neede. */
|
||||
if (priv->row_size_set)
|
||||
{
|
||||
g_object_set (vadjust,
|
||||
"step-increment", priv->row_size,
|
||||
NULL);
|
||||
}
|
||||
|
||||
st_scroll_bar_set_adjustment (ST_SCROLL_BAR(priv->vscroll), vadjust);
|
||||
g_signal_connect (vadjust, "changed", G_CALLBACK (
|
||||
child_adjustment_changed_cb), priv->vscroll);
|
||||
child_adjustment_changed_cb (vadjust, priv->vscroll);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_view_init (StScrollView *self)
|
||||
{
|
||||
StScrollViewPrivate *priv = self->priv = SCROLL_VIEW_PRIVATE (self);
|
||||
|
||||
priv->hscroll = CLUTTER_ACTOR (st_scroll_bar_new (NULL));
|
||||
priv->vscroll = g_object_new (ST_TYPE_SCROLL_BAR, "vertical", TRUE, NULL);
|
||||
|
||||
clutter_actor_set_parent (priv->hscroll, CLUTTER_ACTOR (self));
|
||||
clutter_actor_set_parent (priv->vscroll, CLUTTER_ACTOR (self));
|
||||
|
||||
/* mouse scroll is enabled by default, so we also need to be reactive */
|
||||
priv->mouse_scroll = TRUE;
|
||||
g_object_set (G_OBJECT (self), "reactive", TRUE, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_view_add (ClutterContainer *container,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
StScrollView *self = ST_SCROLL_VIEW (container);
|
||||
StScrollViewPrivate *priv = self->priv;
|
||||
|
||||
if (ST_IS_SCROLLABLE (actor))
|
||||
{
|
||||
priv->child = actor;
|
||||
|
||||
/* chain up to StBin::add() */
|
||||
st_scroll_view_parent_iface->add (container, actor);
|
||||
|
||||
/* Get adjustments for scroll-bars */
|
||||
g_signal_connect (actor, "notify::hadjustment",
|
||||
G_CALLBACK (child_hadjustment_notify_cb),
|
||||
container);
|
||||
g_signal_connect (actor, "notify::vadjustment",
|
||||
G_CALLBACK (child_vadjustment_notify_cb),
|
||||
container);
|
||||
child_hadjustment_notify_cb (G_OBJECT (actor), NULL, container);
|
||||
child_vadjustment_notify_cb (G_OBJECT (actor), NULL, container);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("Attempting to add an actor of type %s to "
|
||||
"a StScrollView, but the actor does "
|
||||
"not implement StScrollable.",
|
||||
g_type_name (G_OBJECT_TYPE (actor)));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_view_remove (ClutterContainer *container,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
StScrollViewPrivate *priv = ST_SCROLL_VIEW (container)->priv;
|
||||
|
||||
if (actor == priv->child)
|
||||
{
|
||||
g_object_ref (priv->child);
|
||||
|
||||
/* chain up to StBin::remove() */
|
||||
st_scroll_view_parent_iface->remove (container, actor);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (priv->child,
|
||||
child_hadjustment_notify_cb,
|
||||
container);
|
||||
g_signal_handlers_disconnect_by_func (priv->child,
|
||||
child_vadjustment_notify_cb,
|
||||
container);
|
||||
st_scrollable_set_adjustments ((StScrollable*) priv->child, NULL, NULL);
|
||||
|
||||
g_object_unref (priv->child);
|
||||
priv->child = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_view_foreach_with_internals (ClutterContainer *container,
|
||||
ClutterCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
StScrollViewPrivate *priv = ST_SCROLL_VIEW (container)->priv;
|
||||
|
||||
if (priv->child != NULL)
|
||||
callback (priv->child, user_data);
|
||||
|
||||
if (priv->hscroll != NULL)
|
||||
callback (priv->hscroll, user_data);
|
||||
|
||||
if (priv->vscroll != NULL)
|
||||
callback (priv->vscroll, user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_container_iface_init (ClutterContainerIface *iface)
|
||||
{
|
||||
/* store a pointer to the StBin implementation of
|
||||
* ClutterContainer so that we can chain up when
|
||||
* overriding the methods
|
||||
*/
|
||||
st_scroll_view_parent_iface = g_type_interface_peek_parent (iface);
|
||||
|
||||
iface->add = st_scroll_view_add;
|
||||
iface->remove = st_scroll_view_remove;
|
||||
iface->foreach_with_internals = st_scroll_view_foreach_with_internals;
|
||||
}
|
||||
|
||||
StWidget *
|
||||
st_scroll_view_new (void)
|
||||
{
|
||||
return g_object_new (ST_TYPE_SCROLL_VIEW, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_scroll_view_get_hscroll_bar:
|
||||
* @scroll: a #StScrollView
|
||||
*
|
||||
* Gets the horizontal scrollbar of the scrollbiew
|
||||
*
|
||||
* Return value: (transfer none): the horizontal #StScrollbar
|
||||
*/
|
||||
ClutterActor *
|
||||
st_scroll_view_get_hscroll_bar (StScrollView *scroll)
|
||||
{
|
||||
g_return_val_if_fail (ST_IS_SCROLL_VIEW (scroll), NULL);
|
||||
|
||||
return scroll->priv->hscroll;
|
||||
}
|
||||
|
||||
/**
|
||||
* st_scroll_view_get_vscroll_bar:
|
||||
* @scroll: a #StScrollView
|
||||
*
|
||||
* Gets the vertical scrollbar of the scrollbiew
|
||||
*
|
||||
* Return value: (transfer none): the vertical #StScrollbar
|
||||
*/
|
||||
ClutterActor *
|
||||
st_scroll_view_get_vscroll_bar (StScrollView *scroll)
|
||||
{
|
||||
g_return_val_if_fail (ST_IS_SCROLL_VIEW (scroll), NULL);
|
||||
|
||||
return scroll->priv->vscroll;
|
||||
}
|
||||
|
||||
gfloat
|
||||
st_scroll_view_get_column_size (StScrollView *scroll)
|
||||
{
|
||||
StAdjustment *adjustment;
|
||||
gdouble column_size;
|
||||
|
||||
g_return_val_if_fail (scroll, 0);
|
||||
|
||||
adjustment = st_scroll_bar_get_adjustment (
|
||||
ST_SCROLL_BAR (scroll->priv->hscroll));
|
||||
g_object_get (adjustment,
|
||||
"step-increment", &column_size,
|
||||
NULL);
|
||||
|
||||
return column_size;
|
||||
}
|
||||
|
||||
void
|
||||
st_scroll_view_set_column_size (StScrollView *scroll,
|
||||
gfloat column_size)
|
||||
{
|
||||
StAdjustment *adjustment;
|
||||
|
||||
g_return_if_fail (scroll);
|
||||
|
||||
if (column_size < 0)
|
||||
{
|
||||
scroll->priv->column_size_set = FALSE;
|
||||
scroll->priv->column_size = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
scroll->priv->column_size_set = TRUE;
|
||||
scroll->priv->column_size = column_size;
|
||||
|
||||
adjustment = st_scroll_bar_get_adjustment (
|
||||
ST_SCROLL_BAR (scroll->priv->hscroll));
|
||||
|
||||
if (adjustment)
|
||||
g_object_set (adjustment,
|
||||
"step-increment", (gdouble) scroll->priv->column_size,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
gfloat
|
||||
st_scroll_view_get_row_size (StScrollView *scroll)
|
||||
{
|
||||
StAdjustment *adjustment;
|
||||
gdouble row_size;
|
||||
|
||||
g_return_val_if_fail (scroll, 0);
|
||||
|
||||
adjustment = st_scroll_bar_get_adjustment (
|
||||
ST_SCROLL_BAR (scroll->priv->vscroll));
|
||||
g_object_get (adjustment,
|
||||
"step-increment", &row_size,
|
||||
NULL);
|
||||
|
||||
return row_size;
|
||||
}
|
||||
|
||||
void
|
||||
st_scroll_view_set_row_size (StScrollView *scroll,
|
||||
gfloat row_size)
|
||||
{
|
||||
StAdjustment *adjustment;
|
||||
|
||||
g_return_if_fail (scroll);
|
||||
|
||||
if (row_size < 0)
|
||||
{
|
||||
scroll->priv->row_size_set = FALSE;
|
||||
scroll->priv->row_size = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
scroll->priv->row_size_set = TRUE;
|
||||
scroll->priv->row_size = row_size;
|
||||
|
||||
adjustment = st_scroll_bar_get_adjustment (
|
||||
ST_SCROLL_BAR (scroll->priv->vscroll));
|
||||
|
||||
if (adjustment)
|
||||
g_object_set (adjustment,
|
||||
"step-increment", (gdouble) scroll->priv->row_size,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
st_scroll_view_set_mouse_scrolling (StScrollView *scroll,
|
||||
gboolean enabled)
|
||||
{
|
||||
StScrollViewPrivate *priv;
|
||||
|
||||
g_return_if_fail (ST_IS_SCROLL_VIEW (scroll));
|
||||
|
||||
priv = ST_SCROLL_VIEW (scroll)->priv;
|
||||
|
||||
if (priv->mouse_scroll != enabled)
|
||||
{
|
||||
priv->mouse_scroll = enabled;
|
||||
|
||||
/* make sure we can receive mouse wheel events */
|
||||
if (enabled)
|
||||
clutter_actor_set_reactive ((ClutterActor *) scroll, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
st_scroll_view_get_mouse_scrolling (StScrollView *scroll)
|
||||
{
|
||||
StScrollViewPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (ST_IS_SCROLL_VIEW (scroll), FALSE);
|
||||
|
||||
priv = ST_SCROLL_VIEW (scroll)->priv;
|
||||
|
||||
return priv->mouse_scroll;
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-scroll-view.h: Container with scroll-bars
|
||||
*
|
||||
* Copyright 2008 OpenedHand
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Written by: Chris Lord <chris@openedhand.com>
|
||||
* Port to St by: Robert Staudinger <robsta@openedhand.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(ST_H_INSIDE) && !defined(ST_COMPILATION)
|
||||
#error "Only <st/st.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef __ST_SCROLL_VIEW_H__
|
||||
#define __ST_SCROLL_VIEW_H__
|
||||
|
||||
#include <st/st-bin.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define ST_TYPE_SCROLL_VIEW (st_scroll_view_get_type())
|
||||
#define ST_SCROLL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_SCROLL_VIEW, StScrollView))
|
||||
#define ST_IS_SCROLL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_SCROLL_VIEW))
|
||||
#define ST_SCROLL_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_SCROLL_VIEW, StScrollViewClass))
|
||||
#define ST_IS_SCROLL_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_SCROLL_VIEW))
|
||||
#define ST_SCROLL_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_SCROLL_VIEW, StScrollViewClass))
|
||||
|
||||
typedef struct _StScrollView StScrollView;
|
||||
typedef struct _StScrollViewPrivate StScrollViewPrivate;
|
||||
typedef struct _StScrollViewClass StScrollViewClass;
|
||||
|
||||
/**
|
||||
* StScrollView:
|
||||
*
|
||||
* The contents of this structure are private and should only be accessed
|
||||
* through the public API.
|
||||
*/
|
||||
struct _StScrollView
|
||||
{
|
||||
/*< private >*/
|
||||
StBin parent_instance;
|
||||
|
||||
StScrollViewPrivate *priv;
|
||||
};
|
||||
|
||||
struct _StScrollViewClass
|
||||
{
|
||||
StBinClass parent_class;
|
||||
};
|
||||
|
||||
GType st_scroll_view_get_type (void) G_GNUC_CONST;
|
||||
|
||||
StWidget *st_scroll_view_new (void);
|
||||
|
||||
ClutterActor *st_scroll_view_get_hscroll_bar (StScrollView *scroll);
|
||||
ClutterActor *st_scroll_view_get_vscroll_bar (StScrollView *scroll);
|
||||
|
||||
gfloat st_scroll_view_get_column_size (StScrollView *scroll);
|
||||
void st_scroll_view_set_column_size (StScrollView *scroll,
|
||||
gfloat column_size);
|
||||
|
||||
gfloat st_scroll_view_get_row_size (StScrollView *scroll);
|
||||
void st_scroll_view_set_row_size (StScrollView *scroll,
|
||||
gfloat row_size);
|
||||
|
||||
void st_scroll_view_set_mouse_scrolling (StScrollView *scroll,
|
||||
gboolean enabled);
|
||||
gboolean st_scroll_view_get_mouse_scrolling (StScrollView *scroll);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __ST_SCROLL_VIEW_H__ */
|
@ -1,97 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-scrollable.c: Scrollable interface
|
||||
*
|
||||
* Copyright 2008 OpenedHand
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Written by: Chris Lord <chris@openedhand.com>
|
||||
* Port to St by: Robert Staudinger <robsta@openedhand.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "st-scrollable.h"
|
||||
|
||||
static void
|
||||
st_scrollable_base_init (gpointer g_iface)
|
||||
{
|
||||
static gboolean initialized = FALSE;
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
g_object_interface_install_property (g_iface,
|
||||
g_param_spec_object ("hadjustment",
|
||||
"StAdjustment",
|
||||
"Horizontal adjustment",
|
||||
ST_TYPE_ADJUSTMENT,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_interface_install_property (g_iface,
|
||||
g_param_spec_object ("vadjustment",
|
||||
"StAdjustment",
|
||||
"Vertical adjustment",
|
||||
ST_TYPE_ADJUSTMENT,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
initialized = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
GType
|
||||
st_scrollable_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
if (type == 0)
|
||||
{
|
||||
static const GTypeInfo info =
|
||||
{
|
||||
sizeof (StScrollableInterface),
|
||||
st_scrollable_base_init, /* base_init */
|
||||
NULL,
|
||||
};
|
||||
type = g_type_register_static (G_TYPE_INTERFACE,
|
||||
"StScrollable", &info, 0);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
void
|
||||
st_scrollable_set_adjustments (StScrollable *scrollable,
|
||||
StAdjustment *hadjustment,
|
||||
StAdjustment *vadjustment)
|
||||
{
|
||||
ST_SCROLLABLE_GET_INTERFACE (scrollable)->set_adjustments (scrollable,
|
||||
hadjustment,
|
||||
vadjustment);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_scroll_bar_get_adjustments:
|
||||
* @hadjustment: (transfer none) (out) (allow-none): location to store the horizontal adjustment, or %NULL
|
||||
* @vadjustment: (transfer none) (out) (allow-none): location to store the vertical adjustment, or %NULL
|
||||
*
|
||||
* Gets the adjustment objects that store the offsets of the scrollable widget
|
||||
* into its possible scrolling area.
|
||||
*/
|
||||
void
|
||||
st_scrollable_get_adjustments (StScrollable *scrollable,
|
||||
StAdjustment **hadjustment,
|
||||
StAdjustment **vadjustment)
|
||||
{
|
||||
ST_SCROLLABLE_GET_INTERFACE (scrollable)->get_adjustments (scrollable,
|
||||
hadjustment,
|
||||
vadjustment);
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-scrollable.h: Scrollable interface
|
||||
*
|
||||
* Copyright 2008 OpenedHand
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Written by: Chris Lord <chris@openedhand.com>
|
||||
* Port to St by: Robert Staudinger <robsta@openedhand.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(ST_H_INSIDE) && !defined(ST_COMPILATION)
|
||||
#error "Only <st/st.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef __ST_SCROLLABLE_H__
|
||||
#define __ST_SCROLLABLE_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <st/st-adjustment.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define ST_TYPE_SCROLLABLE (st_scrollable_get_type ())
|
||||
#define ST_SCROLLABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_SCROLLABLE, StScrollable))
|
||||
#define ST_IS_SCROLLABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_SCROLLABLE))
|
||||
#define ST_SCROLLABLE_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), ST_TYPE_SCROLLABLE, StScrollableInterface))
|
||||
|
||||
typedef struct _StScrollable StScrollable; /* Dummy object */
|
||||
typedef struct _StScrollableInterface StScrollableInterface;
|
||||
|
||||
struct _StScrollableInterface
|
||||
{
|
||||
GTypeInterface parent;
|
||||
|
||||
void (* set_adjustments) (StScrollable *scrollable,
|
||||
StAdjustment *hadjustment,
|
||||
StAdjustment *vadjustment);
|
||||
void (* get_adjustments) (StScrollable *scrollable,
|
||||
StAdjustment **hadjustment,
|
||||
StAdjustment **vadjustment);
|
||||
};
|
||||
|
||||
GType st_scrollable_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void st_scrollable_set_adjustments (StScrollable *scrollable,
|
||||
StAdjustment *hadjustment,
|
||||
StAdjustment *vadjustment);
|
||||
void st_scrollable_get_adjustments (StScrollable *scrollable,
|
||||
StAdjustment **hadjustment,
|
||||
StAdjustment **vadjustment);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __ST_SCROLLABLE_H__ */
|
@ -1,97 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-subtexture.h: Class to wrap a texture and "subframe" it.
|
||||
*
|
||||
* Based on
|
||||
* st-texture-frame.h: Expandible texture actor
|
||||
*
|
||||
* Copyright 2007, 2008 OpenedHand Ltd
|
||||
* Copyright 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(ST_H_INSIDE) && !defined(ST_COMPILATION)
|
||||
#error "Only <st/st.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef __ST_SUBTEXTURE_H__
|
||||
#define __ST_SUBTEXTURE_H__
|
||||
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define ST_TYPE_SUBTEXTURE (st_subtexture_get_type ())
|
||||
#define ST_SUBTEXTURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_SUBTEXTURE, StSubtexture))
|
||||
#define ST_SUBTEXTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_SUBTEXTURE, StSubtextureClass))
|
||||
#define ST_IS_SUBTEXTURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_SUBTEXTURE))
|
||||
#define ST_IS_SUBTEXTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_SUBTEXTURE))
|
||||
#define ST_SUBTEXTURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_SUBTEXTURE, StSubtextureClass))
|
||||
|
||||
typedef struct _StSubtexture StSubtexture;
|
||||
typedef struct _StSubtexturePrivate StSubtexturePrivate;
|
||||
typedef struct _StSubtextureClass StSubtextureClass;
|
||||
|
||||
/**
|
||||
* StSubtexture:
|
||||
*
|
||||
* The contents of this structure are private and should only be accessed
|
||||
* through the public API.
|
||||
*/
|
||||
struct _StSubtexture
|
||||
{
|
||||
/*< private >*/
|
||||
ClutterActor parent_instance;
|
||||
|
||||
StSubtexturePrivate *priv;
|
||||
};
|
||||
|
||||
struct _StSubtextureClass
|
||||
{
|
||||
ClutterActorClass parent_class;
|
||||
|
||||
/* padding for future expansion */
|
||||
void (*_st_box_1) (void);
|
||||
void (*_st_box_2) (void);
|
||||
void (*_st_box_3) (void);
|
||||
void (*_st_box_4) (void);
|
||||
};
|
||||
|
||||
GType st_subtexture_get_type (void) G_GNUC_CONST;
|
||||
|
||||
ClutterActor * st_subtexture_new (ClutterTexture *texture,
|
||||
gint top,
|
||||
gint left,
|
||||
gint width,
|
||||
gint height);
|
||||
void st_subtexture_set_parent_texture (StSubtexture *frame,
|
||||
ClutterTexture *texture);
|
||||
ClutterTexture *st_subtexture_get_parent_texture (StSubtexture *frame);
|
||||
void st_subtexture_set_frame (StSubtexture *frame,
|
||||
gint top,
|
||||
gint left,
|
||||
gint width,
|
||||
gint height);
|
||||
void st_subtexture_get_frame (StSubtexture *frame,
|
||||
gint *top,
|
||||
gint *left,
|
||||
gint *width,
|
||||
gint *height);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __ST_SUBTEXTURE_H__ */
|
@ -1,805 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-table-child.h: Table child implementation
|
||||
*
|
||||
* Copyright 2008, 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Written by: Thomas Wood <thomas.wood@intel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "st-private.h"
|
||||
#include "st-table-child.h"
|
||||
#include "st-table-private.h"
|
||||
#include <st/st-widget.h>
|
||||
#include <st/st-table.h>
|
||||
|
||||
/*
|
||||
* ClutterChildMeta Implementation
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:st-table-child
|
||||
* @short_description: The child property store for #StTable
|
||||
*
|
||||
* The #ClutterChildMeta implementation for the #StTable container widget.
|
||||
*
|
||||
*/
|
||||
|
||||
enum {
|
||||
CHILD_PROP_0,
|
||||
|
||||
CHILD_PROP_COL,
|
||||
CHILD_PROP_ROW,
|
||||
CHILD_PROP_COL_SPAN,
|
||||
CHILD_PROP_ROW_SPAN,
|
||||
CHILD_PROP_X_EXPAND,
|
||||
CHILD_PROP_Y_EXPAND,
|
||||
CHILD_PROP_X_ALIGN,
|
||||
CHILD_PROP_Y_ALIGN,
|
||||
CHILD_PROP_X_FILL,
|
||||
CHILD_PROP_Y_FILL,
|
||||
CHILD_PROP_ALLOCATE_HIDDEN,
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (StTableChild, st_table_child, CLUTTER_TYPE_CHILD_META);
|
||||
|
||||
static void
|
||||
table_child_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StTableChild *child = ST_TABLE_CHILD (gobject);
|
||||
StTable *table = ST_TABLE (CLUTTER_CHILD_META(gobject)->container);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case CHILD_PROP_COL:
|
||||
child->col = g_value_get_int (value);
|
||||
_st_table_update_row_col (table, -1, child->col);
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (table));
|
||||
break;
|
||||
case CHILD_PROP_ROW:
|
||||
child->row = g_value_get_int (value);
|
||||
_st_table_update_row_col (table, child->row, -1);
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (table));
|
||||
break;
|
||||
case CHILD_PROP_COL_SPAN:
|
||||
child->col_span = g_value_get_int (value);
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (table));
|
||||
break;
|
||||
case CHILD_PROP_ROW_SPAN:
|
||||
child->row_span = g_value_get_int (value);
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (table));
|
||||
break;
|
||||
case CHILD_PROP_X_EXPAND:
|
||||
child->x_expand = g_value_get_boolean (value);
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (table));
|
||||
break;
|
||||
case CHILD_PROP_Y_EXPAND:
|
||||
child->y_expand = g_value_get_boolean (value);
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (table));
|
||||
break;
|
||||
case CHILD_PROP_X_ALIGN:
|
||||
child->x_align = g_value_get_double (value);
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (table));
|
||||
break;
|
||||
case CHILD_PROP_Y_ALIGN:
|
||||
child->y_align = g_value_get_double (value);
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (table));
|
||||
break;
|
||||
case CHILD_PROP_X_FILL:
|
||||
child->x_fill = g_value_get_boolean (value);
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (table));
|
||||
break;
|
||||
case CHILD_PROP_Y_FILL:
|
||||
child->y_fill = g_value_get_boolean (value);
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (table));
|
||||
break;
|
||||
case CHILD_PROP_ALLOCATE_HIDDEN:
|
||||
child->allocate_hidden = g_value_get_boolean (value);
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (table));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
table_child_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StTableChild *child = ST_TABLE_CHILD (gobject);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case CHILD_PROP_COL:
|
||||
g_value_set_int (value, child->col);
|
||||
break;
|
||||
case CHILD_PROP_ROW:
|
||||
g_value_set_int (value, child->row);
|
||||
break;
|
||||
case CHILD_PROP_COL_SPAN:
|
||||
g_value_set_int (value, child->col_span);
|
||||
break;
|
||||
case CHILD_PROP_ROW_SPAN:
|
||||
g_value_set_int (value, child->row_span);
|
||||
break;
|
||||
case CHILD_PROP_X_EXPAND:
|
||||
g_value_set_boolean (value, child->x_expand);
|
||||
break;
|
||||
case CHILD_PROP_Y_EXPAND:
|
||||
g_value_set_boolean (value, child->y_expand);
|
||||
break;
|
||||
case CHILD_PROP_X_ALIGN:
|
||||
g_value_set_double (value, child->x_align);
|
||||
break;
|
||||
case CHILD_PROP_Y_ALIGN:
|
||||
g_value_set_double (value, child->y_align);
|
||||
break;
|
||||
case CHILD_PROP_X_FILL:
|
||||
g_value_set_boolean (value, child->x_fill);
|
||||
break;
|
||||
case CHILD_PROP_Y_FILL:
|
||||
g_value_set_boolean (value, child->y_fill);
|
||||
break;
|
||||
case CHILD_PROP_ALLOCATE_HIDDEN:
|
||||
g_value_set_boolean (value, child->allocate_hidden);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
st_table_child_class_init (StTableChildClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
GParamSpec *pspec;
|
||||
|
||||
gobject_class->set_property = table_child_set_property;
|
||||
gobject_class->get_property = table_child_get_property;
|
||||
|
||||
pspec = g_param_spec_int ("col",
|
||||
"Column Number",
|
||||
"The column the widget resides in",
|
||||
0, G_MAXINT,
|
||||
0,
|
||||
ST_PARAM_READWRITE);
|
||||
|
||||
g_object_class_install_property (gobject_class, CHILD_PROP_COL, pspec);
|
||||
|
||||
pspec = g_param_spec_int ("row",
|
||||
"Row Number",
|
||||
"The row the widget resides in",
|
||||
0, G_MAXINT,
|
||||
0,
|
||||
ST_PARAM_READWRITE);
|
||||
|
||||
g_object_class_install_property (gobject_class, CHILD_PROP_ROW, pspec);
|
||||
|
||||
pspec = g_param_spec_int ("row-span",
|
||||
"Row Span",
|
||||
"The number of rows the widget should span",
|
||||
1, G_MAXINT,
|
||||
1,
|
||||
ST_PARAM_READWRITE);
|
||||
|
||||
g_object_class_install_property (gobject_class, CHILD_PROP_ROW_SPAN, pspec);
|
||||
|
||||
pspec = g_param_spec_int ("col-span",
|
||||
"Column Span",
|
||||
"The number of columns the widget should span",
|
||||
1, G_MAXINT,
|
||||
1,
|
||||
ST_PARAM_READWRITE);
|
||||
|
||||
g_object_class_install_property (gobject_class, CHILD_PROP_COL_SPAN, pspec);
|
||||
|
||||
pspec = g_param_spec_boolean ("x-expand",
|
||||
"X Expand",
|
||||
"Whether the child should receive priority "
|
||||
"when the container is allocating spare space "
|
||||
"on the horizontal axis",
|
||||
TRUE,
|
||||
ST_PARAM_READWRITE);
|
||||
|
||||
g_object_class_install_property (gobject_class, CHILD_PROP_X_EXPAND, pspec);
|
||||
|
||||
pspec = g_param_spec_boolean ("y-expand",
|
||||
"Y Expand",
|
||||
"Whether the child should receive priority "
|
||||
"when the container is allocating spare space "
|
||||
"on the vertical axis",
|
||||
TRUE,
|
||||
ST_PARAM_READWRITE);
|
||||
|
||||
g_object_class_install_property (gobject_class, CHILD_PROP_Y_EXPAND, pspec);
|
||||
|
||||
pspec = g_param_spec_double ("x-align",
|
||||
"X Alignment",
|
||||
"X alignment of the widget within the cell",
|
||||
0, 1,
|
||||
0.5,
|
||||
ST_PARAM_READWRITE);
|
||||
|
||||
g_object_class_install_property (gobject_class, CHILD_PROP_X_ALIGN, pspec);
|
||||
|
||||
pspec = g_param_spec_double ("y-align",
|
||||
"Y Alignment",
|
||||
"Y alignment of the widget within the cell",
|
||||
0, 1,
|
||||
0.5,
|
||||
ST_PARAM_READWRITE);
|
||||
|
||||
g_object_class_install_property (gobject_class, CHILD_PROP_Y_ALIGN, pspec);
|
||||
|
||||
pspec = g_param_spec_boolean ("x-fill",
|
||||
"X Fill",
|
||||
"Whether the child should be allocated its "
|
||||
"entire available space, or whether it should "
|
||||
"be squashed and aligned.",
|
||||
TRUE,
|
||||
ST_PARAM_READWRITE);
|
||||
|
||||
g_object_class_install_property (gobject_class, CHILD_PROP_X_FILL, pspec);
|
||||
|
||||
pspec = g_param_spec_boolean ("y-fill",
|
||||
"Y Fill",
|
||||
"Whether the child should be allocated its "
|
||||
"entire available space, or whether it should "
|
||||
"be squashed and aligned.",
|
||||
TRUE,
|
||||
ST_PARAM_READWRITE);
|
||||
|
||||
g_object_class_install_property (gobject_class, CHILD_PROP_Y_FILL, pspec);
|
||||
|
||||
pspec = g_param_spec_boolean ("allocate-hidden",
|
||||
"Allocate Hidden",
|
||||
"Whether the child should be allocate even "
|
||||
"if it is hidden",
|
||||
TRUE,
|
||||
ST_PARAM_READWRITE);
|
||||
|
||||
g_object_class_install_property (gobject_class, CHILD_PROP_ALLOCATE_HIDDEN, pspec);
|
||||
}
|
||||
|
||||
static void
|
||||
st_table_child_init (StTableChild *self)
|
||||
{
|
||||
self->col_span = 1;
|
||||
self->row_span = 1;
|
||||
|
||||
self->x_align = 0.5;
|
||||
self->y_align = 0.5;
|
||||
|
||||
self->x_expand = TRUE;
|
||||
self->y_expand = TRUE;
|
||||
|
||||
self->x_fill = TRUE;
|
||||
self->y_fill = TRUE;
|
||||
|
||||
self->allocate_hidden = TRUE;
|
||||
}
|
||||
|
||||
static StTableChild*
|
||||
get_child_meta (StTable *table,
|
||||
ClutterActor *child)
|
||||
{
|
||||
StTableChild *meta;
|
||||
|
||||
meta = (StTableChild*) clutter_container_get_child_meta (CLUTTER_CONTAINER (table), child);
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* st_table_child_get_col_span:
|
||||
* @table: an #StTable
|
||||
* @child: a #ClutterActor
|
||||
*
|
||||
* Get the column span of the child. Defaults to 1.
|
||||
*
|
||||
* Returns: the column span of the child
|
||||
*/
|
||||
gint
|
||||
st_table_child_get_col_span (StTable *table,
|
||||
ClutterActor *child)
|
||||
{
|
||||
StTableChild *meta;
|
||||
|
||||
g_return_val_if_fail (ST_IS_TABLE (table), 0);
|
||||
g_return_val_if_fail (CLUTTER_IS_ACTOR (child), 0);
|
||||
|
||||
meta = get_child_meta (table, child);
|
||||
|
||||
return meta->col_span;
|
||||
}
|
||||
|
||||
/**
|
||||
* st_table_child_set_col_span:
|
||||
* @table: An #StTable
|
||||
* @child: An #ClutterActor
|
||||
* @span: The number of columns to span
|
||||
*
|
||||
* Set the column span of the child.
|
||||
*
|
||||
*/
|
||||
void
|
||||
st_table_child_set_col_span (StTable *table,
|
||||
ClutterActor *child,
|
||||
gint span)
|
||||
{
|
||||
StTableChild *meta;
|
||||
|
||||
g_return_if_fail (ST_IS_TABLE (table));
|
||||
g_return_if_fail (CLUTTER_IS_ACTOR (child));
|
||||
g_return_if_fail (span > 1);
|
||||
|
||||
meta = get_child_meta (table, child);
|
||||
|
||||
meta->col_span = span;
|
||||
|
||||
clutter_actor_queue_relayout (child);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_table_child_get_row_span:
|
||||
* @table: A #StTable
|
||||
* @child: A #ClutterActor
|
||||
*
|
||||
* Get the row span of the child. Defaults to 1.
|
||||
*
|
||||
* Returns: the row span of the child
|
||||
*/
|
||||
gint
|
||||
st_table_child_get_row_span (StTable *table,
|
||||
ClutterActor *child)
|
||||
{
|
||||
StTableChild *meta;
|
||||
|
||||
g_return_val_if_fail (ST_IS_TABLE (table), 0);
|
||||
g_return_val_if_fail (CLUTTER_IS_ACTOR (child), 0);
|
||||
|
||||
meta = get_child_meta (table, child);
|
||||
|
||||
return meta->row_span;
|
||||
}
|
||||
|
||||
/**
|
||||
* st_table_child_set_row_span:
|
||||
* @table: A #StTable
|
||||
* @child: A #ClutterActor
|
||||
* @span: the number of rows to span
|
||||
*
|
||||
* Set the row span of the child.
|
||||
*
|
||||
*/
|
||||
void
|
||||
st_table_child_set_row_span (StTable *table,
|
||||
ClutterActor *child,
|
||||
gint span)
|
||||
{
|
||||
StTableChild *meta;
|
||||
|
||||
g_return_if_fail (ST_IS_TABLE (table));
|
||||
g_return_if_fail (CLUTTER_IS_ACTOR (child));
|
||||
g_return_if_fail (span > 1);
|
||||
|
||||
meta = get_child_meta (table, child);
|
||||
|
||||
meta->row_span = span;
|
||||
|
||||
clutter_actor_queue_relayout (child);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_table_child_get_x_fill:
|
||||
* @table: A #StTable
|
||||
* @child: A #ClutterActor
|
||||
*
|
||||
* Get the x-fill state of the child
|
||||
*
|
||||
* Returns: #TRUE if the child is set to x-fill
|
||||
*/
|
||||
gboolean
|
||||
st_table_child_get_x_fill (StTable *table,
|
||||
ClutterActor *child)
|
||||
{
|
||||
StTableChild *meta;
|
||||
|
||||
g_return_val_if_fail (ST_IS_TABLE (table), 0);
|
||||
g_return_val_if_fail (CLUTTER_IS_ACTOR (child), 0);
|
||||
|
||||
meta = get_child_meta (table, child);
|
||||
|
||||
return meta->x_fill;
|
||||
}
|
||||
|
||||
/**
|
||||
* st_table_child_set_x_fill:
|
||||
* @table: A #StTable
|
||||
* @child: A #ClutterActor
|
||||
* @fill: the fill state
|
||||
*
|
||||
* Set the fill state of the child on the x-axis. This will cause the child to
|
||||
* be allocated the maximum available space.
|
||||
*
|
||||
*/
|
||||
void
|
||||
st_table_child_set_x_fill (StTable *table,
|
||||
ClutterActor *child,
|
||||
gboolean fill)
|
||||
{
|
||||
StTableChild *meta;
|
||||
|
||||
g_return_if_fail (ST_IS_TABLE (table));
|
||||
g_return_if_fail (CLUTTER_IS_ACTOR (child));
|
||||
|
||||
meta = get_child_meta (table, child);
|
||||
|
||||
meta->x_fill = fill;
|
||||
|
||||
clutter_actor_queue_relayout (child);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* st_table_child_get_y_fill:
|
||||
* @table: A #StTable
|
||||
* @child: A #ClutterActor
|
||||
*
|
||||
* Get the y-fill state of the child
|
||||
*
|
||||
* Returns: #TRUE if the child is set to y-fill
|
||||
*/
|
||||
gboolean
|
||||
st_table_child_get_y_fill (StTable *table,
|
||||
ClutterActor *child)
|
||||
{
|
||||
StTableChild *meta;
|
||||
|
||||
g_return_val_if_fail (ST_IS_TABLE (table), 0);
|
||||
g_return_val_if_fail (CLUTTER_IS_ACTOR (child), 0);
|
||||
|
||||
meta = get_child_meta (table, child);
|
||||
|
||||
return meta->y_fill;
|
||||
}
|
||||
|
||||
/**
|
||||
* st_table_child_set_y_fill:
|
||||
* @table: A #StTable
|
||||
* @child: A #ClutterActor
|
||||
* @fill: the fill state
|
||||
*
|
||||
* Set the fill state of the child on the y-axis. This will cause the child to
|
||||
* be allocated the maximum available space.
|
||||
*
|
||||
*/
|
||||
void
|
||||
st_table_child_set_y_fill (StTable *table,
|
||||
ClutterActor *child,
|
||||
gboolean fill)
|
||||
{
|
||||
StTableChild *meta;
|
||||
|
||||
g_return_if_fail (ST_IS_TABLE (table));
|
||||
g_return_if_fail (CLUTTER_IS_ACTOR (child));
|
||||
|
||||
meta = get_child_meta (table, child);
|
||||
|
||||
meta->y_fill = fill;
|
||||
|
||||
clutter_actor_queue_relayout (child);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_table_child_get_x_expand:
|
||||
* @table: A #StTable
|
||||
* @child: A #ClutterActor
|
||||
*
|
||||
* Get the x-expand property of the child
|
||||
*
|
||||
* Returns: #TRUE if the child is set to x-expand
|
||||
*/
|
||||
gboolean
|
||||
st_table_child_get_x_expand (StTable *table,
|
||||
ClutterActor *child)
|
||||
{
|
||||
StTableChild *meta;
|
||||
|
||||
g_return_val_if_fail (ST_IS_TABLE (table), 0);
|
||||
g_return_val_if_fail (CLUTTER_IS_ACTOR (child), 0);
|
||||
|
||||
meta = get_child_meta (table, child);
|
||||
|
||||
return meta->x_expand;
|
||||
}
|
||||
|
||||
/**
|
||||
* st_table_child_set_x_expand:
|
||||
* @table: A #StTable
|
||||
* @child: A #ClutterActor
|
||||
* @expand: the new value of the x expand child property
|
||||
*
|
||||
* Set x-expand on the child. This causes the column which the child
|
||||
* resides in to be allocated any extra space if the allocation of the table is
|
||||
* larger than the preferred size.
|
||||
*
|
||||
*/
|
||||
void
|
||||
st_table_child_set_x_expand (StTable *table,
|
||||
ClutterActor *child,
|
||||
gboolean expand)
|
||||
{
|
||||
StTableChild *meta;
|
||||
|
||||
g_return_if_fail (ST_IS_TABLE (table));
|
||||
g_return_if_fail (CLUTTER_IS_ACTOR (child));
|
||||
|
||||
meta = get_child_meta (table, child);
|
||||
|
||||
meta->x_expand = expand;
|
||||
|
||||
clutter_actor_queue_relayout (child);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_table_child_set_y_expand:
|
||||
* @table: A #StTable
|
||||
* @child: A #ClutterActor
|
||||
* @expand: the new value of the y-expand child property
|
||||
*
|
||||
* Set y-expand on the child. This causes the row which the child
|
||||
* resides in to be allocated any extra space if the allocation of the table is
|
||||
* larger than the preferred size.
|
||||
*
|
||||
*/
|
||||
void
|
||||
st_table_child_set_y_expand (StTable *table,
|
||||
ClutterActor *child,
|
||||
gboolean expand)
|
||||
{
|
||||
StTableChild *meta;
|
||||
|
||||
g_return_if_fail (ST_IS_TABLE (table));
|
||||
g_return_if_fail (CLUTTER_IS_ACTOR (child));
|
||||
|
||||
meta = get_child_meta (table, child);
|
||||
|
||||
meta->y_expand = expand;
|
||||
|
||||
clutter_actor_queue_relayout (child);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_table_child_get_y_expand:
|
||||
* @table: A #StTable
|
||||
* @child: A #ClutterActor
|
||||
*
|
||||
* Get the y-expand property of the child.
|
||||
*
|
||||
* Returns: #TRUE if the child is set to y-expand
|
||||
*/
|
||||
gboolean
|
||||
st_table_child_get_y_expand (StTable *table,
|
||||
ClutterActor *child)
|
||||
{
|
||||
StTableChild *meta;
|
||||
|
||||
g_return_val_if_fail (ST_IS_TABLE (table), 0);
|
||||
g_return_val_if_fail (CLUTTER_IS_ACTOR (child), 0);
|
||||
|
||||
meta = get_child_meta (table, child);
|
||||
|
||||
return meta->y_expand;
|
||||
}
|
||||
|
||||
/**
|
||||
* st_table_child_get_x_align:
|
||||
* @table: A #StTable
|
||||
* @child: A #ClutterActor
|
||||
*
|
||||
* Get the x-align value of the child
|
||||
*
|
||||
* Returns: An #StAlign value
|
||||
*/
|
||||
StAlign
|
||||
st_table_child_get_x_align (StTable *table,
|
||||
ClutterActor *child)
|
||||
{
|
||||
StTableChild *meta;
|
||||
|
||||
g_return_val_if_fail (ST_IS_TABLE (table), 0);
|
||||
g_return_val_if_fail (CLUTTER_IS_ACTOR (child), 0);
|
||||
|
||||
meta = get_child_meta (table, child);
|
||||
|
||||
if (meta->x_align == 0.0)
|
||||
return ST_ALIGN_START;
|
||||
else if (meta->x_align == 1.0)
|
||||
return ST_ALIGN_END;
|
||||
else
|
||||
return ST_ALIGN_MIDDLE;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* st_table_child_set_x_align:
|
||||
* @table: A #StTable
|
||||
* @child: A #ClutterActor
|
||||
* @align: A #StAlign value
|
||||
*
|
||||
* Set the alignment of the child within its cell. This will only have an effect
|
||||
* if the the x-fill property is FALSE.
|
||||
*
|
||||
*/
|
||||
void
|
||||
st_table_child_set_x_align (StTable *table,
|
||||
ClutterActor *child,
|
||||
StAlign align)
|
||||
{
|
||||
StTableChild *meta;
|
||||
|
||||
g_return_if_fail (ST_IS_TABLE (table));
|
||||
g_return_if_fail (CLUTTER_IS_ACTOR (child));
|
||||
|
||||
meta = get_child_meta (table, child);
|
||||
|
||||
switch (align)
|
||||
{
|
||||
case ST_ALIGN_START:
|
||||
meta->x_align = 0.0;
|
||||
break;
|
||||
case ST_ALIGN_MIDDLE:
|
||||
meta->x_align = 0.5;
|
||||
break;
|
||||
case ST_ALIGN_END:
|
||||
meta->x_align = 1.0;
|
||||
break;
|
||||
}
|
||||
|
||||
clutter_actor_queue_relayout (child);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_table_child_get_y_align:
|
||||
* @table: A #StTable
|
||||
* @child: A #ClutterActor
|
||||
*
|
||||
* Get the y-align value of the child
|
||||
*
|
||||
* Returns: An #StAlign value
|
||||
*/
|
||||
StAlign
|
||||
st_table_child_get_y_align (StTable *table,
|
||||
ClutterActor *child)
|
||||
{
|
||||
StTableChild *meta;
|
||||
|
||||
g_return_val_if_fail (ST_IS_TABLE (table), 0);
|
||||
g_return_val_if_fail (CLUTTER_IS_ACTOR (child), 0);
|
||||
|
||||
meta = get_child_meta (table, child);
|
||||
|
||||
if (meta->y_align == 0.0)
|
||||
return ST_ALIGN_START;
|
||||
else if (meta->y_align == 1.0)
|
||||
return ST_ALIGN_END;
|
||||
else
|
||||
return ST_ALIGN_MIDDLE;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* st_table_child_set_y_align:
|
||||
* @table: A #StTable
|
||||
* @child: A #ClutterActor
|
||||
* @align: A #StAlign value
|
||||
*
|
||||
* Set the value of the y-align property. This will only have an effect if
|
||||
* y-fill value is set to FALSE.
|
||||
*
|
||||
*/
|
||||
void
|
||||
st_table_child_set_y_align (StTable *table,
|
||||
ClutterActor *child,
|
||||
StAlign align)
|
||||
{
|
||||
StTableChild *meta;
|
||||
|
||||
g_return_if_fail (ST_IS_TABLE (table));
|
||||
g_return_if_fail (CLUTTER_IS_ACTOR (child));
|
||||
|
||||
meta = get_child_meta (table, child);
|
||||
|
||||
switch (align)
|
||||
{
|
||||
case ST_ALIGN_START:
|
||||
meta->y_align = 0.0;
|
||||
break;
|
||||
case ST_ALIGN_MIDDLE:
|
||||
meta->y_align = 0.5;
|
||||
break;
|
||||
case ST_ALIGN_END:
|
||||
meta->y_align = 1.0;
|
||||
break;
|
||||
}
|
||||
|
||||
clutter_actor_queue_relayout (child);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_table_child_set_allocate_hidden:
|
||||
* @table: A #StTable
|
||||
* @child: A #ClutterActor
|
||||
* @value: #TRUE if the actor should be allocated when hidden
|
||||
*
|
||||
* Set whether the child should be allocate even if it is hidden
|
||||
*/
|
||||
void
|
||||
st_table_child_set_allocate_hidden (StTable *table,
|
||||
ClutterActor *child,
|
||||
gboolean value)
|
||||
{
|
||||
StTableChild *meta;
|
||||
|
||||
g_return_if_fail (ST_IS_TABLE (table));
|
||||
g_return_if_fail (CLUTTER_IS_ACTOR (child));
|
||||
|
||||
meta = get_child_meta (table, child);
|
||||
|
||||
if (meta->allocate_hidden != value)
|
||||
{
|
||||
meta->allocate_hidden = value;
|
||||
|
||||
clutter_actor_queue_relayout (child);
|
||||
|
||||
g_object_notify (G_OBJECT (meta), "allocate-hidden");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* st_table_child_get_allocate_hidden:
|
||||
* @table: A #StTable
|
||||
* @child: A #ClutterActor
|
||||
*
|
||||
* Determine if the child is allocated even if it is hidden
|
||||
*
|
||||
* Returns: #TRUE if the actor is allocated when hidden
|
||||
*/
|
||||
gboolean
|
||||
st_table_child_get_allocate_hidden (StTable *table,
|
||||
ClutterActor *child)
|
||||
{
|
||||
StTableChild *meta;
|
||||
|
||||
g_return_val_if_fail (ST_IS_TABLE (table), TRUE);
|
||||
g_return_val_if_fail (CLUTTER_IS_ACTOR (child), TRUE);
|
||||
|
||||
meta = get_child_meta (table, child);
|
||||
|
||||
return meta->allocate_hidden;
|
||||
}
|
@ -1,129 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* st-table-child.h: Table child implementation
|
||||
*
|
||||
* Copyright 2008, 2009 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Written by: Thomas Wood <thomas@linux.intel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(ST_H_INSIDE) && !defined(ST_COMPILATION)
|
||||
#error "Only <st/st.h> can be included directly.h"
|
||||
#endif
|
||||
|
||||
#ifndef __ST_TABLE_CHILD_H__
|
||||
#define __ST_TABLE_CHILD_H__
|
||||
|
||||
#include <st/st-types.h>
|
||||
#include <st/st-widget.h>
|
||||
#include <st/st-table.h>
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define ST_TYPE_TABLE_CHILD (st_table_child_get_type ())
|
||||
#define ST_TABLE_CHILD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_TABLE_CHILD, StTableChild))
|
||||
#define ST_IS_TABLE_CHILD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_TABLE_CHILD))
|
||||
#define ST_TABLE_CHILD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_TABLE_CHILD, StTableChildClass))
|
||||
#define ST_IS_TABLE_CHILD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_TABLE_CHILD))
|
||||
#define ST_TABLE_CHILD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_TABLE_CHILD, StTableChildClass))
|
||||
|
||||
typedef struct _StTableChild StTableChild;
|
||||
typedef struct _StTableChildClass StTableChildClass;
|
||||
|
||||
/**
|
||||
* StTableChild:
|
||||
*
|
||||
* The contents of the this structure are private and should only be accessed
|
||||
* through the public API.
|
||||
*/
|
||||
struct _StTableChild
|
||||
{
|
||||
/*< private >*/
|
||||
ClutterChildMeta parent_instance;
|
||||
|
||||
gint col;
|
||||
gint row;
|
||||
gint col_span;
|
||||
gint row_span;
|
||||
gdouble x_align;
|
||||
gdouble y_align;
|
||||
guint allocate_hidden : 1;
|
||||
guint x_expand : 1;
|
||||
guint y_expand : 1;
|
||||
guint x_fill : 1;
|
||||
guint y_fill : 1;
|
||||
};
|
||||
|
||||
|
||||
struct _StTableChildClass
|
||||
{
|
||||
ClutterChildMetaClass parent_class;
|
||||
};
|
||||
|
||||
GType st_table_child_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gint st_table_child_get_col_span (StTable *table,
|
||||
ClutterActor *child);
|
||||
void st_table_child_set_col_span (StTable *table,
|
||||
ClutterActor *child,
|
||||
gint span);
|
||||
gint st_table_child_get_row_span (StTable *table,
|
||||
ClutterActor *child);
|
||||
void st_table_child_set_row_span (StTable *table,
|
||||
ClutterActor *child,
|
||||
gint span);
|
||||
gboolean st_table_child_get_x_fill (StTable *table,
|
||||
ClutterActor *child);
|
||||
void st_table_child_set_x_fill (StTable *table,
|
||||
ClutterActor *child,
|
||||
gboolean fill);
|
||||
gboolean st_table_child_get_y_fill (StTable *table,
|
||||
ClutterActor *child);
|
||||
void st_table_child_set_y_fill (StTable *table,
|
||||
ClutterActor *child,
|
||||
gboolean fill);
|
||||
gboolean st_table_child_get_x_expand (StTable *table,
|
||||
ClutterActor *child);
|
||||
void st_table_child_set_x_expand (StTable *table,
|
||||
ClutterActor *child,
|
||||
gboolean expand);
|
||||
gboolean st_table_child_get_y_expand (StTable *table,
|
||||
ClutterActor *child);
|
||||
void st_table_child_set_y_expand (StTable *table,
|
||||
ClutterActor *child,
|
||||
gboolean expand);
|
||||
StAlign st_table_child_get_x_align (StTable *table,
|
||||
ClutterActor *child);
|
||||
void st_table_child_set_x_align (StTable *table,
|
||||
ClutterActor *child,
|
||||
StAlign align);
|
||||
StAlign st_table_child_get_y_align (StTable *table,
|
||||
ClutterActor *child);
|
||||
void st_table_child_set_y_align (StTable *table,
|
||||
ClutterActor *child,
|
||||
StAlign align);
|
||||
void st_table_child_set_allocate_hidden (StTable *table,
|
||||
ClutterActor *child,
|
||||
gboolean value);
|
||||
gboolean st_table_child_get_allocate_hidden (StTable *table,
|
||||
ClutterActor *child);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __ST_TABLE_H__ */
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user