Merge branch 'master' into datetime
This commit is contained in:
commit
b7fe72e74a
@ -92,12 +92,15 @@ StScrollBar StButton#vhandle:hover
|
||||
background-color: #292929;
|
||||
}
|
||||
|
||||
StTooltip {
|
||||
border: 1px solid rgba(79,111,173,0.9);
|
||||
StTooltip StLabel {
|
||||
border: 1px solid rgba(79,111,173,1);
|
||||
border-radius: 5px;
|
||||
padding: 4px;
|
||||
background-color: rgba(79,111,173,0.9);
|
||||
color: #ffffff;
|
||||
font-size: 0.8em;
|
||||
font-weight: normal;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* PopupMenu */
|
||||
@ -153,6 +156,10 @@ StTooltip {
|
||||
-slider-handle-radius: 0.5em;
|
||||
}
|
||||
|
||||
.popup-device-menu-item {
|
||||
spacing: .5em;
|
||||
}
|
||||
|
||||
.popup-menu-icon {
|
||||
icon-size: 1em;
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ nobase_dist_js_DATA = \
|
||||
ui/statusIconDispatcher.js \
|
||||
ui/statusMenu.js \
|
||||
ui/status/accessibility.js \
|
||||
ui/status/power.js \
|
||||
ui/status/volume.js \
|
||||
ui/telepathyClient.js \
|
||||
ui/tweener.js \
|
||||
|
11
js/ui/dnd.js
11
js/ui/dnd.js
@ -267,6 +267,7 @@ _Draggable.prototype = {
|
||||
|
||||
this._dragActor.reparent(this.actor.get_stage());
|
||||
this._dragActor.raise_top();
|
||||
Shell.util_set_hidden_from_pick(this._dragActor, true);
|
||||
|
||||
this._dragOrigOpacity = this._dragActor.opacity;
|
||||
if (this._dragActorOpacity != undefined)
|
||||
@ -332,12 +333,8 @@ _Draggable.prototype = {
|
||||
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, stageY);
|
||||
this._dragActor.show();
|
||||
|
||||
// We call observers only once per motion with the innermost
|
||||
// target actor. If necessary, the observer can walk the
|
||||
@ -384,13 +381,9 @@ _Draggable.prototype = {
|
||||
},
|
||||
|
||||
_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();
|
||||
let [dropX, dropY] = event.get_coords();
|
||||
let target = this._dragActor.get_stage().get_actor_at_pos(Clutter.PickMode.ALL,
|
||||
dropX, dropY);
|
||||
this._dragActor.show();
|
||||
|
||||
// We call observers only once per motion with the innermost
|
||||
// target actor. If necessary, the observer can walk the
|
||||
@ -522,6 +515,8 @@ _Draggable.prototype = {
|
||||
},
|
||||
|
||||
_dragComplete: function() {
|
||||
Shell.util_set_hidden_from_pick(this._dragActor, false);
|
||||
|
||||
this._dragActor = undefined;
|
||||
currentDraggable = null;
|
||||
this._ungrabEvents();
|
||||
|
@ -97,10 +97,11 @@ function start() {
|
||||
Shell.WindowTracker.get_default();
|
||||
Shell.AppUsage.get_default();
|
||||
|
||||
// The background color really only matters if there is no desktop
|
||||
// window (say, nautilus) running. We set it mostly so things look good
|
||||
// when we are running inside Xephyr.
|
||||
// The stage is always covered so Clutter doesn't need to clear it; however
|
||||
// the color is used as the default contents for the Mutter root background
|
||||
// actor so set it anyways.
|
||||
global.stage.color = DEFAULT_BACKGROUND_COLOR;
|
||||
global.stage.no_clear_hint = true;
|
||||
|
||||
let themeContext = St.ThemeContext.get_for_stage (global.stage);
|
||||
let stylesheetPath = global.datadir + '/theme/gnome-shell.css';
|
||||
@ -161,10 +162,6 @@ function start() {
|
||||
}
|
||||
});
|
||||
|
||||
background = global.create_root_pixmap_actor();
|
||||
global.stage.add_actor(background);
|
||||
background.lower_bottom();
|
||||
|
||||
global.gdk_screen.connect('monitors-changed', _relayout);
|
||||
|
||||
ExtensionSystem.init();
|
||||
@ -240,8 +237,6 @@ function _relayout() {
|
||||
panel.actor.set_size(primary.width, Panel.PANEL_HEIGHT);
|
||||
overview.relayout();
|
||||
|
||||
background.set_size(global.screen_width, global.screen_height);
|
||||
|
||||
// To avoid updating the position and size of the workspaces
|
||||
// in the overview, we just hide the overview. The positions
|
||||
// will be updated when it is next shown. We do the same for
|
||||
|
@ -34,6 +34,7 @@ const STANDARD_TRAY_ICON_ORDER = ['a11y', 'display', 'keyboard', 'volume', 'blue
|
||||
const STANDARD_TRAY_ICON_SHELL_IMPLEMENTATION = {
|
||||
'a11y': imports.ui.status.accessibility.ATIndicator,
|
||||
'volume': imports.ui.status.volume.Indicator,
|
||||
'battery': imports.ui.status.power.Indicator
|
||||
};
|
||||
|
||||
function AnimatedIcon(name, size) {
|
||||
|
@ -72,18 +72,19 @@ SystemStatusButton.prototype = {
|
||||
|
||||
_init: function(iconName,tooltipText) {
|
||||
Button.prototype._init.call(this, St.Align.START);
|
||||
this._iconActor = null;
|
||||
this.setIcon(iconName);
|
||||
this._iconActor = new St.Icon({ icon_name: iconName,
|
||||
icon_type: St.IconType.SYMBOLIC,
|
||||
style_class: 'system-status-icon' });
|
||||
this.actor.set_child(this._iconActor);
|
||||
this.setTooltip(tooltipText);
|
||||
},
|
||||
|
||||
setIcon: function(iconName) {
|
||||
this._iconName = iconName;
|
||||
if (this._iconActor)
|
||||
this._iconActor.destroy();
|
||||
this._iconActor = new St.Icon({ icon_name: this._iconName,
|
||||
style_class: 'system-status-icon' });
|
||||
this.actor.set_child(this._iconActor);
|
||||
this._iconActor.icon_name = iconName;
|
||||
},
|
||||
|
||||
setGIcon: function(gicon) {
|
||||
this._iconActor.gicon = gicon;
|
||||
},
|
||||
|
||||
setTooltip: function(text) {
|
||||
@ -96,4 +97,4 @@ SystemStatusButton.prototype = {
|
||||
this.tooltip = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -79,7 +79,7 @@ PlaceDeviceInfo.prototype = {
|
||||
|
||||
iconFactory: function(size) {
|
||||
let icon = this._mount.get_icon();
|
||||
return St.TextureCache.get_default().load_gicon(icon, size);
|
||||
return St.TextureCache.get_default().load_gicon(null, icon, size);
|
||||
},
|
||||
|
||||
launch: function() {
|
||||
@ -137,7 +137,7 @@ PlacesManager.prototype = {
|
||||
let homeIcon = Shell.util_get_icon_for_uri (homeUri);
|
||||
this._home = new PlaceInfo('special:home', homeLabel,
|
||||
function(size) {
|
||||
return St.TextureCache.get_default().load_gicon(homeIcon, size);
|
||||
return St.TextureCache.get_default().load_gicon(null, homeIcon, size);
|
||||
},
|
||||
function() {
|
||||
Gio.app_info_launch_default_for_uri(homeUri, global.create_app_launch_context());
|
||||
@ -150,7 +150,7 @@ PlacesManager.prototype = {
|
||||
let desktopIcon = Shell.util_get_icon_for_uri (desktopUri);
|
||||
this._desktopMenu = new PlaceInfo('special:desktop', desktopLabel,
|
||||
function(size) {
|
||||
return St.TextureCache.get_default().load_gicon(desktopIcon, size);
|
||||
return St.TextureCache.get_default().load_gicon(null, desktopIcon, size);
|
||||
},
|
||||
function() {
|
||||
Gio.app_info_launch_default_for_uri(desktopUri, global.create_app_launch_context());
|
||||
@ -327,7 +327,7 @@ PlacesManager.prototype = {
|
||||
|
||||
let item = new PlaceInfo('bookmark:' + bookmark, label,
|
||||
function(size) {
|
||||
return St.TextureCache.get_default().load_gicon(icon, size);
|
||||
return St.TextureCache.get_default().load_gicon(null, icon, size);
|
||||
},
|
||||
function() {
|
||||
Gio.app_info_launch_default_for_uri(bookmark, global.create_app_launch_context());
|
||||
|
@ -679,8 +679,11 @@ PopupMenu.prototype = {
|
||||
}));
|
||||
},
|
||||
|
||||
addMenuItem: function(menuItem) {
|
||||
this._box.add(menuItem.actor);
|
||||
addMenuItem: function(menuItem, position) {
|
||||
if (position == undefined)
|
||||
this._box.add(menuItem.actor);
|
||||
else
|
||||
this._box.insert_actor(menuItem.actor, position);
|
||||
menuItem._activeChangeId = menuItem.connect('active-changed', Lang.bind(this, function (menuItem, active) {
|
||||
if (active && this._activeMenuItem != menuItem) {
|
||||
if (this._activeMenuItem)
|
||||
|
226
js/ui/status/power.js
Normal file
226
js/ui/status/power.js
Normal file
@ -0,0 +1,226 @@
|
||||
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
|
||||
|
||||
const Gio = imports.gi.Gio;
|
||||
const GLib = imports.gi.GLib;
|
||||
const DBus = imports.dbus;
|
||||
const Lang = imports.lang;
|
||||
const Mainloop = imports.mainloop;
|
||||
const Shell = imports.gi.Shell;
|
||||
const St = imports.gi.St;
|
||||
|
||||
const PanelMenu = imports.ui.panelMenu;
|
||||
const PopupMenu = imports.ui.popupMenu;
|
||||
|
||||
const Gettext = imports.gettext.domain('gnome-shell');
|
||||
const _ = Gettext.gettext;
|
||||
|
||||
const BUS_NAME = 'org.gnome.PowerManager';
|
||||
const OBJECT_PATH = '/org/gnome/PowerManager';
|
||||
|
||||
const UPDeviceType = {
|
||||
UNKNOWN: 0,
|
||||
AC_POWER: 1,
|
||||
BATTERY: 2,
|
||||
UPS: 3,
|
||||
MONITOR: 4,
|
||||
MOUSE: 5,
|
||||
KEYBOARD: 6,
|
||||
PDA: 7,
|
||||
PHONE: 8
|
||||
};
|
||||
|
||||
const UPDeviceState = {
|
||||
UNKNOWN: 0,
|
||||
CHARGING: 1,
|
||||
DISCHARGING: 2,
|
||||
EMPTY: 3,
|
||||
FULLY_CHARGED: 4,
|
||||
PENDING_CHARGE: 5,
|
||||
PENDING_DISCHARGE: 6
|
||||
};
|
||||
|
||||
const PowerManagerInterface = {
|
||||
name: 'org.gnome.PowerManager',
|
||||
methods: [
|
||||
{ name: 'GetDevices', inSignature: '', outSignature: 'a(susbut)' },
|
||||
{ name: 'GetPrimaryDevice', inSignature: '', outSignature: '(susbut)' },
|
||||
],
|
||||
signals: [
|
||||
{ name: 'Changed', outSignature: '' },
|
||||
],
|
||||
properties: [
|
||||
{ name: 'Icon', signature: 's', access: 'read' },
|
||||
]
|
||||
};
|
||||
let PowerManagerProxy = DBus.makeProxyClass(PowerManagerInterface);
|
||||
|
||||
function Indicator() {
|
||||
this._init.apply(this, arguments);
|
||||
}
|
||||
|
||||
Indicator.prototype = {
|
||||
__proto__: PanelMenu.SystemStatusButton.prototype,
|
||||
|
||||
_init: function() {
|
||||
PanelMenu.SystemStatusButton.prototype._init.call(this, 'battery-missing');
|
||||
this._proxy = new PowerManagerProxy(DBus.session, BUS_NAME, OBJECT_PATH);
|
||||
|
||||
this._deviceItems = [ ];
|
||||
this._hasPrimary = false;
|
||||
this._primaryDeviceId = null;
|
||||
this._batteryItem = new PopupMenu.PopupMenuItem('');
|
||||
this.menu.addMenuItem(this._batteryItem);
|
||||
this._deviceSep = new PopupMenu.PopupSeparatorMenuItem();
|
||||
this.menu.addMenuItem(this._deviceSep);
|
||||
this._otherDevicePosition = 2;
|
||||
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
||||
this.menu.addAction(_("What's using power..."),function() {
|
||||
GLib.spawn_command_line_async('gnome-power-statistics --device wakeups');
|
||||
});
|
||||
this.menu.addAction(_("Power Settings"),function() {
|
||||
GLib.spawn_command_line_async('gnome-control-center power');
|
||||
});
|
||||
|
||||
this._proxy.connect('Changed', Lang.bind(this, this._devicesChanged));
|
||||
this._devicesChanged();
|
||||
},
|
||||
|
||||
_readPrimaryDevice: function() {
|
||||
this._proxy.GetPrimaryDeviceRemote(Lang.bind(this, function(device, error) {
|
||||
if (error) {
|
||||
this._checkError(error);
|
||||
this._hasPrimary = false;
|
||||
this._primaryDeviceId = null;
|
||||
this._batteryItem.actor.hide();
|
||||
this._deviceSep.actor.hide();
|
||||
return;
|
||||
}
|
||||
let [device_id, device_type, summary, percentage, state, time] = device;
|
||||
if (device_type == UPDeviceType.BATTERY) {
|
||||
this._hasPrimary = true;
|
||||
this._batteryItem.label.text = summary;
|
||||
this._batteryItem.actor.show();
|
||||
if (this._deviceItems.length > 0)
|
||||
this._deviceSep.actor.show();
|
||||
} else {
|
||||
this._hasPrimary = false;
|
||||
this._batteryItem.actor.hide();
|
||||
this._deviceSep.actor.hide();
|
||||
}
|
||||
|
||||
this._primaryDeviceId = device_id;
|
||||
}));
|
||||
},
|
||||
|
||||
_readOtherDevices: function() {
|
||||
this._proxy.GetDevicesRemote(Lang.bind(this, function(devices, error) {
|
||||
this._deviceItems.forEach(function(i) { i.destroy(); });
|
||||
this._deviceItems = [];
|
||||
|
||||
if (error) {
|
||||
this._checkError(error);
|
||||
this._deviceSep.actor.hide();
|
||||
return;
|
||||
}
|
||||
|
||||
let position = 0;
|
||||
for (let i = 0; i < devices.length; i++) {
|
||||
let [device_id, device_type] = devices[i];
|
||||
if (device_type == UPDeviceType.AC_POWER || device_id == this._primaryDeviceId)
|
||||
continue;
|
||||
|
||||
let item = new DeviceItem (devices[i]);
|
||||
item.connect('activate', function() {
|
||||
let p = new Shell.Process({ args: ['gnome-power-statistics', '--device', device_id] });
|
||||
p.run();
|
||||
});
|
||||
this._deviceItems.push(item);
|
||||
this.menu.addMenuItem(item, this._otherDevicePosition + position);
|
||||
position++;
|
||||
}
|
||||
|
||||
if (this._hasPrimary && position > 0)
|
||||
this._deviceSep.actor.show();
|
||||
else
|
||||
this._deviceSep.actor.hide();
|
||||
}));
|
||||
},
|
||||
|
||||
_devicesChanged: function() {
|
||||
this._proxy.GetRemote('Icon', Lang.bind(this, function(icon, error) {
|
||||
if (icon) {
|
||||
let gicon = Shell.util_icon_from_string (icon);
|
||||
this.setGIcon(gicon);
|
||||
this.actor.show();
|
||||
} else {
|
||||
this._checkError(error);
|
||||
this.menu.close();
|
||||
this.actor.hide();
|
||||
}
|
||||
}));
|
||||
this._readPrimaryDevice();
|
||||
this._readOtherDevices();
|
||||
},
|
||||
|
||||
_checkError: function(error) {
|
||||
if (!this._restarted && error && error.message.match(/org\.freedesktop\.DBus\.Error\.(UnknownMethod|InvalidArgs)/)) {
|
||||
GLib.spawn_command_line_sync('pkill -f "^gnome-power-manager$"');
|
||||
GLib.spawn_command_line_async('gnome-power-manager');
|
||||
this._restarted = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function DeviceItem() {
|
||||
this._init.apply(this, arguments);
|
||||
}
|
||||
|
||||
DeviceItem.prototype = {
|
||||
__proto__: PopupMenu.PopupBaseMenuItem.prototype,
|
||||
|
||||
_init: function(device) {
|
||||
PopupMenu.PopupBaseMenuItem.prototype._init.call(this);
|
||||
|
||||
let [device_id, device_type, summary, percentage, state, time] = device;
|
||||
|
||||
this._box = new St.BoxLayout({ style_class: 'popup-device-menu-item' });
|
||||
this._label = new St.Label({ text: summary });
|
||||
|
||||
let icon;
|
||||
switch (state) {
|
||||
case UPDeviceState.FULLY_CHARGED:
|
||||
icon = 'battery-full-charged';
|
||||
break;
|
||||
case UPDeviceState.UNKNOWN:
|
||||
icon = 'battery-missing';
|
||||
break;
|
||||
default:
|
||||
icon = this._percentageToIcon(percentage) + (state == UPDeviceState.CHARGING ? '-charging' : '');
|
||||
}
|
||||
|
||||
this._icon = new St.Icon({ icon_name: icon,
|
||||
icon_type: St.IconType.SYMBOLIC,
|
||||
style_class: 'popup-menu-icon' });
|
||||
|
||||
this._box.add_actor(this._icon);
|
||||
this._box.add_actor(this._label);
|
||||
this.addActor(this._box);
|
||||
|
||||
let percentBin = new St.Bin({ x_align: St.Align.END });
|
||||
let percentLabel = new St.Label({ text: '%d%%'.format(Math.round(percentage)) });
|
||||
percentBin.child = percentLabel;
|
||||
this.addActor(percentBin);
|
||||
},
|
||||
|
||||
_percentageToIcon: function(p) {
|
||||
if (p > 60)
|
||||
return 'battery-full';
|
||||
if (p > 30)
|
||||
return 'battery-good';
|
||||
if (p > 10)
|
||||
return 'battery-low';
|
||||
if (p > 0)
|
||||
return 'battery-caution';
|
||||
return 'battery-empty';
|
||||
}
|
||||
}
|
@ -347,9 +347,9 @@ ContactManager.prototype = {
|
||||
let uri = GLib.filename_to_uri(file, null);
|
||||
iconBox.child = textureCache.load_uri_async(uri, iconBox._size, iconBox._size);
|
||||
} else {
|
||||
iconBox.child = St.Icon({ icon_name: 'stock_person',
|
||||
icon_type: St.IconType.FULLCOLOR,
|
||||
icon_size: iconBox._size });
|
||||
iconBox.child = new St.Icon({ icon_name: 'stock_person',
|
||||
icon_type: St.IconType.FULLCOLOR,
|
||||
icon_size: iconBox._size });
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -301,7 +301,7 @@ DesktopClone.prototype = {
|
||||
_init : function(window) {
|
||||
this.actor = new Clutter.Group({ reactive: true });
|
||||
|
||||
let background = new Clutter.Clone({ source: Main.background.source });
|
||||
let background = new Clutter.Clone({ source: global.background_actor });
|
||||
this.actor.add_actor(background);
|
||||
|
||||
if (window) {
|
||||
|
@ -77,7 +77,7 @@ shell_public_headers_h = \
|
||||
shell-stack.h \
|
||||
shell-tray-icon.h \
|
||||
shell-tray-manager.h \
|
||||
shell-uri-util.h \
|
||||
shell-util.h \
|
||||
shell-window-tracker.h \
|
||||
shell-wm.h \
|
||||
shell-xfixes-cursor.h
|
||||
@ -109,7 +109,7 @@ libgnome_shell_la_SOURCES = \
|
||||
shell-stack.c \
|
||||
shell-tray-icon.c \
|
||||
shell-tray-manager.c \
|
||||
shell-uri-util.c \
|
||||
shell-util.c \
|
||||
shell-window-tracker.c \
|
||||
shell-wm.c \
|
||||
shell-xfixes-cursor.c
|
||||
|
@ -1274,7 +1274,7 @@ shell_app_info_create_icon_texture (ShellAppInfo *info, float size)
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = st_texture_cache_load_gicon (st_texture_cache_get_default (), icon, (int)size);
|
||||
ret = st_texture_cache_load_gicon (st_texture_cache_get_default (), NULL, icon, (int)size);
|
||||
g_object_unref (icon);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,6 @@
|
||||
#define MAGNIFIER_DBUS_SERVICE "org.gnome.Magnifier"
|
||||
|
||||
static void grab_notify (GtkWidget *widget, gboolean is_grab, gpointer user_data);
|
||||
static void update_root_window_pixmap (ShellGlobal *global);
|
||||
|
||||
struct _ShellGlobal {
|
||||
GObject parent;
|
||||
@ -87,6 +86,7 @@ enum {
|
||||
PROP_STAGE,
|
||||
PROP_STAGE_INPUT_MODE,
|
||||
PROP_WINDOW_GROUP,
|
||||
PROP_BACKGROUND_ACTOR,
|
||||
PROP_WINDOW_MANAGER,
|
||||
PROP_SETTINGS,
|
||||
PROP_DATADIR,
|
||||
@ -161,6 +161,9 @@ shell_global_get_property(GObject *object,
|
||||
case PROP_WINDOW_GROUP:
|
||||
g_value_set_object (value, meta_plugin_get_window_group (global->plugin));
|
||||
break;
|
||||
case PROP_BACKGROUND_ACTOR:
|
||||
g_value_set_object (value, meta_plugin_get_background_actor (global->plugin));
|
||||
break;
|
||||
case PROP_WINDOW_MANAGER:
|
||||
g_value_set_object (value, global->wm);
|
||||
break;
|
||||
@ -299,6 +302,13 @@ shell_global_class_init (ShellGlobalClass *klass)
|
||||
"Actor holding window actors",
|
||||
CLUTTER_TYPE_ACTOR,
|
||||
G_PARAM_READABLE));
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_BACKGROUND_ACTOR,
|
||||
g_param_spec_object ("background-actor",
|
||||
"Background Actor",
|
||||
"Actor drawing root window background",
|
||||
CLUTTER_TYPE_ACTOR,
|
||||
G_PARAM_READABLE));
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_WINDOW_MANAGER,
|
||||
g_param_spec_object ("window-manager",
|
||||
@ -1134,77 +1144,6 @@ grab_notify (GtkWidget *widget, gboolean was_grabbed, gpointer user_data)
|
||||
shell_global_set_stage_input_mode (global, global->input_mode);
|
||||
}
|
||||
|
||||
/*
|
||||
* Updates the global->root_pixmap actor with the root window's pixmap or fails
|
||||
* with a warning.
|
||||
*/
|
||||
static void
|
||||
update_root_window_pixmap (ShellGlobal *global)
|
||||
{
|
||||
Atom type;
|
||||
int format;
|
||||
gulong nitems;
|
||||
gulong bytes_after;
|
||||
guchar *data;
|
||||
Pixmap root_pixmap_id = None;
|
||||
|
||||
if (!XGetWindowProperty (gdk_x11_get_default_xdisplay (),
|
||||
gdk_x11_get_default_root_xwindow (),
|
||||
gdk_x11_get_xatom_by_name ("_XROOTPMAP_ID"),
|
||||
0, LONG_MAX,
|
||||
False,
|
||||
AnyPropertyType,
|
||||
&type, &format, &nitems, &bytes_after, &data) &&
|
||||
type != None)
|
||||
{
|
||||
/* Got a property. */
|
||||
if (type == XA_PIXMAP && format == 32 && nitems == 1)
|
||||
{
|
||||
/* Was what we expected. */
|
||||
root_pixmap_id = *(Pixmap *)data;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("Could not get the root window pixmap");
|
||||
}
|
||||
|
||||
XFree(data);
|
||||
}
|
||||
|
||||
clutter_x11_texture_pixmap_set_pixmap (CLUTTER_X11_TEXTURE_PIXMAP (global->root_pixmap),
|
||||
root_pixmap_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when the X server emits a root window change event. If the event is
|
||||
* about a new pixmap, update the global->root_pixmap actor.
|
||||
*/
|
||||
static GdkFilterReturn
|
||||
root_window_filter (GdkXEvent *native, GdkEvent *event, gpointer data)
|
||||
{
|
||||
XEvent *xevent = (XEvent *)native;
|
||||
|
||||
if ((xevent->type == PropertyNotify) &&
|
||||
(xevent->xproperty.window == gdk_x11_get_default_root_xwindow ()) &&
|
||||
(xevent->xproperty.atom == gdk_x11_get_xatom_by_name ("_XROOTPMAP_ID")))
|
||||
update_root_window_pixmap (SHELL_GLOBAL (data));
|
||||
|
||||
return GDK_FILTER_CONTINUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when the root window pixmap actor is destroyed.
|
||||
*/
|
||||
static void
|
||||
root_pixmap_destroy (GObject *sender, gpointer data)
|
||||
{
|
||||
ShellGlobal *global = SHELL_GLOBAL (data);
|
||||
|
||||
gdk_window_remove_filter (gdk_get_default_root_window (),
|
||||
root_window_filter, global);
|
||||
global->root_pixmap = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* shell_global_format_time_relative_pretty:
|
||||
* @global:
|
||||
@ -1253,80 +1192,6 @@ shell_global_format_time_relative_pretty (ShellGlobal *global,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* shell_global_create_root_pixmap_actor:
|
||||
* @global: a #ShellGlobal
|
||||
*
|
||||
* Creates an actor showing the root window pixmap.
|
||||
*
|
||||
* Return value: (transfer none): a #ClutterActor with the root window pixmap.
|
||||
* The actor is floating, hence (transfer none).
|
||||
*/
|
||||
ClutterActor *
|
||||
shell_global_create_root_pixmap_actor (ShellGlobal *global)
|
||||
{
|
||||
GdkWindow *window;
|
||||
ClutterActor *stage;
|
||||
ClutterColor stage_color;
|
||||
|
||||
/* The actor created is actually a ClutterClone of global->root_pixmap. */
|
||||
|
||||
if (global->root_pixmap == NULL)
|
||||
{
|
||||
global->root_pixmap = clutter_glx_texture_pixmap_new ();
|
||||
|
||||
clutter_actor_set_size (CLUTTER_ACTOR (global->root_pixmap),
|
||||
global->last_change_screen_width,
|
||||
global->last_change_screen_height);
|
||||
|
||||
clutter_texture_set_repeat (CLUTTER_TEXTURE (global->root_pixmap),
|
||||
TRUE, TRUE);
|
||||
|
||||
/* The low and medium quality filters give nearest-neighbor resizing. */
|
||||
clutter_texture_set_filter_quality (CLUTTER_TEXTURE (global->root_pixmap),
|
||||
CLUTTER_TEXTURE_QUALITY_HIGH);
|
||||
|
||||
/* Initialize to the stage color, since that's what will be seen
|
||||
* in the main view if there's no actual background window.
|
||||
*/
|
||||
stage = meta_plugin_get_stage (global->plugin);
|
||||
clutter_stage_get_color (CLUTTER_STAGE (stage), &stage_color);
|
||||
clutter_texture_set_from_rgb_data (CLUTTER_TEXTURE (global->root_pixmap),
|
||||
/* ClutterColor has the same layout
|
||||
* as one pixel of RGB(A) data.
|
||||
*/
|
||||
(const guchar *)&stage_color, FALSE,
|
||||
/* w, h, rowstride, bpp, flags */
|
||||
1, 1, 3, 3, 0, NULL);
|
||||
|
||||
/* We can only clone an actor within a stage, so we hide the source
|
||||
* texture then add it to the stage */
|
||||
clutter_actor_hide (global->root_pixmap);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage),
|
||||
global->root_pixmap);
|
||||
|
||||
/* This really should never happen; but just in case... */
|
||||
g_signal_connect (global->root_pixmap, "destroy",
|
||||
G_CALLBACK (root_pixmap_destroy), global);
|
||||
|
||||
/* Metacity handles changes to some root window properties in its global
|
||||
* event filter, though not _XROOTPMAP_ID. For all root window property
|
||||
* changes, the global filter returns GDK_FILTER_CONTINUE, so our
|
||||
* window specific filter will be called after the global one.
|
||||
*
|
||||
* Because Metacity is already handling root window property updates,
|
||||
* we don't have to worry about adding the PropertyChange mask to the
|
||||
* root window to get PropertyNotify events.
|
||||
*/
|
||||
window = gdk_get_default_root_window ();
|
||||
gdk_window_add_filter (window, root_window_filter, global);
|
||||
|
||||
update_root_window_pixmap (global);
|
||||
}
|
||||
|
||||
return clutter_clone_new (global->root_pixmap);
|
||||
}
|
||||
|
||||
/**
|
||||
* shell_global_get_monitors:
|
||||
* @global: the #ShellGlobal
|
||||
|
@ -89,8 +89,6 @@ void shell_global_maybe_gc (ShellGlobal *global);
|
||||
|
||||
void shell_global_format_time_relative_pretty (ShellGlobal *global, guint delta, char **text, guint *next_update);
|
||||
|
||||
ClutterActor *shell_global_create_root_pixmap_actor (ShellGlobal *global);
|
||||
|
||||
GSList *shell_global_get_monitors (ShellGlobal *global);
|
||||
MetaRectangle *shell_global_get_primary_monitor (ShellGlobal *global);
|
||||
MetaRectangle *shell_global_get_focus_monitor (ShellGlobal *global);
|
||||
|
@ -264,6 +264,8 @@ on_plug_added (GtkSocket *socket,
|
||||
child = g_hash_table_lookup (manager->priv->icons, socket);
|
||||
|
||||
child->actor = shell_tray_icon_new (SHELL_EMBEDDED_WINDOW (child->window));
|
||||
g_object_ref_sink (child->actor);
|
||||
|
||||
g_signal_emit (manager, shell_tray_manager_signals[TRAY_ICON_ADDED], 0,
|
||||
child->actor);
|
||||
}
|
||||
|
@ -1,15 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
#ifndef __SHELL_URI_UTIL_H__
|
||||
#define __SHELL_URI_UTIL_H__
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
char *shell_util_get_label_for_uri (const char *text_uri);
|
||||
GIcon *shell_util_get_icon_for_uri (const char *text_uri);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __SHELL_URI_UTIL_H__ */
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "shell-uri-util.h"
|
||||
#include "shell-util.h"
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <gconf/gconf-client.h>
|
||||
#include <gtk/gtk.h>
|
||||
@ -383,3 +383,59 @@ shell_util_get_icon_for_uri (const char *text_uri)
|
||||
|
||||
return g_themed_icon_new ("gtk-file");
|
||||
}
|
||||
|
||||
/**
|
||||
* shell_util_icon_from_string:
|
||||
* @string: a stringified #GIcon
|
||||
*
|
||||
* A static method equivalent to g_icon_new_for_string, workaround
|
||||
* for GJS not being able to represent Gio.Icon (which is an interface,
|
||||
* not a class).
|
||||
*
|
||||
* Returns: (transfer full): the icon which is represented by @string
|
||||
*/
|
||||
GIcon *
|
||||
shell_util_icon_from_string (const char *string, GError **error)
|
||||
{
|
||||
return g_icon_new_for_string (string, error);
|
||||
}
|
||||
|
||||
static void
|
||||
stop_pick (ClutterActor *actor,
|
||||
const ClutterColor *color)
|
||||
{
|
||||
g_signal_stop_emission_by_name (actor, "pick");
|
||||
}
|
||||
|
||||
/**
|
||||
* shell_util_set_hidden_from_pick:
|
||||
* @actor: A #ClutterActor
|
||||
* @hidden: Whether @actor should be hidden from pick
|
||||
*
|
||||
* If @hidden is %TRUE, hide @actor from pick even with a mode of
|
||||
* %CLUTTER_PICK_ALL; if @hidden is %FALSE, unhide @actor.
|
||||
*/
|
||||
void
|
||||
shell_util_set_hidden_from_pick (ClutterActor *actor,
|
||||
gboolean hidden)
|
||||
{
|
||||
gpointer existing_handler_data;
|
||||
|
||||
existing_handler_data = g_object_get_data (G_OBJECT (actor),
|
||||
"shell-stop-pick");
|
||||
if (hidden)
|
||||
{
|
||||
if (existing_handler_data != NULL)
|
||||
return;
|
||||
g_signal_connect (actor, "pick", G_CALLBACK (stop_pick), NULL);
|
||||
g_object_set_data (G_OBJECT (actor),
|
||||
"shell-stop-pick", GUINT_TO_POINTER (1));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existing_handler_data == NULL)
|
||||
return;
|
||||
g_signal_handlers_disconnect_by_func (actor, stop_pick, NULL);
|
||||
g_object_set_data (G_OBJECT (actor), "shell-stop-pick", NULL);
|
||||
}
|
||||
}
|
18
src/shell-util.h
Normal file
18
src/shell-util.h
Normal file
@ -0,0 +1,18 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
#ifndef __SHELL_UTIL_H__
|
||||
#define __SHELL_UTIL_H__
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
char *shell_util_get_label_for_uri (const char *text_uri);
|
||||
GIcon *shell_util_get_icon_for_uri (const char *text_uri);
|
||||
GIcon *shell_util_icon_from_string (const char *string, GError **error);
|
||||
void shell_util_set_hidden_from_pick (ClutterActor *actor, gboolean hidden);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __SHELL_UTIL_H__ */
|
@ -941,7 +941,7 @@ shell_startup_sequence_create_icon (ShellStartupSequence *sequence, guint size)
|
||||
|
||||
themed = g_themed_icon_new (icon_name);
|
||||
texture = st_texture_cache_load_gicon (st_texture_cache_get_default (),
|
||||
themed, size);
|
||||
NULL, themed, size);
|
||||
g_object_unref (G_OBJECT (themed));
|
||||
return texture;
|
||||
}
|
||||
|
121
src/st/st-icon.c
121
src/st/st-icon.c
@ -35,6 +35,7 @@ enum
|
||||
{
|
||||
PROP_0,
|
||||
|
||||
PROP_GICON,
|
||||
PROP_ICON_NAME,
|
||||
PROP_ICON_TYPE,
|
||||
PROP_ICON_SIZE
|
||||
@ -49,6 +50,7 @@ struct _StIconPrivate
|
||||
{
|
||||
ClutterActor *icon_texture;
|
||||
|
||||
GIcon *gicon;
|
||||
gchar *icon_name;
|
||||
StIconType icon_type;
|
||||
gint prop_icon_size; /* icon size set as property */
|
||||
@ -72,6 +74,10 @@ st_icon_set_property (GObject *gobject,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_GICON:
|
||||
st_icon_set_gicon (icon, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_ICON_NAME:
|
||||
st_icon_set_icon_name (icon, g_value_get_string (value));
|
||||
break;
|
||||
@ -100,6 +106,10 @@ st_icon_get_property (GObject *gobject,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_GICON:
|
||||
g_value_set_object (value, icon->priv->gicon);
|
||||
break;
|
||||
|
||||
case PROP_ICON_NAME:
|
||||
g_value_set_string (value, st_icon_get_icon_name (icon));
|
||||
break;
|
||||
@ -129,6 +139,12 @@ st_icon_dispose (GObject *gobject)
|
||||
priv->icon_texture = NULL;
|
||||
}
|
||||
|
||||
if (priv->gicon)
|
||||
{
|
||||
g_object_unref (priv->gicon);
|
||||
priv->gicon = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (st_icon_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
@ -272,6 +288,13 @@ st_icon_class_init (StIconClass *klass)
|
||||
|
||||
widget_class->style_changed = st_icon_style_changed;
|
||||
|
||||
pspec = g_param_spec_object ("gicon",
|
||||
"GIcon",
|
||||
"A GIcon to override :icon-name",
|
||||
G_TYPE_ICON,
|
||||
ST_PARAM_READWRITE);
|
||||
g_object_class_install_property (object_class, PROP_GICON, pspec);
|
||||
|
||||
pspec = g_param_spec_string ("icon-name",
|
||||
"Icon name",
|
||||
"An icon name",
|
||||
@ -299,6 +322,7 @@ st_icon_init (StIcon *self)
|
||||
{
|
||||
self->priv = ST_ICON_GET_PRIVATE (self);
|
||||
|
||||
self->priv->gicon = NULL;
|
||||
self->priv->icon_size = DEFAULT_ICON_SIZE;
|
||||
self->priv->prop_icon_size = -1;
|
||||
self->priv->icon_type = DEFAULT_ICON_TYPE;
|
||||
@ -308,6 +332,8 @@ static void
|
||||
st_icon_update (StIcon *icon)
|
||||
{
|
||||
StIconPrivate *priv = icon->priv;
|
||||
StThemeNode *theme_node;
|
||||
StTextureCache *cache;
|
||||
|
||||
/* Get rid of the old one */
|
||||
if (priv->icon_texture)
|
||||
@ -317,23 +343,30 @@ st_icon_update (StIcon *icon)
|
||||
}
|
||||
|
||||
/* Try to lookup the new one */
|
||||
if (priv->icon_name)
|
||||
theme_node = st_widget_peek_theme_node (ST_WIDGET (icon));
|
||||
if (theme_node == NULL)
|
||||
return;
|
||||
|
||||
cache = st_texture_cache_get_default ();
|
||||
if (priv->gicon)
|
||||
{
|
||||
StThemeNode *theme_node = st_widget_peek_theme_node (ST_WIDGET (icon));
|
||||
|
||||
if (theme_node)
|
||||
{
|
||||
StTextureCache *cache = st_texture_cache_get_default ();
|
||||
priv->icon_texture = st_texture_cache_load_icon_name (cache,
|
||||
theme_node,
|
||||
priv->icon_name,
|
||||
priv->icon_type,
|
||||
priv->icon_size);
|
||||
|
||||
if (priv->icon_texture)
|
||||
clutter_actor_set_parent (priv->icon_texture, CLUTTER_ACTOR (icon));
|
||||
}
|
||||
priv->icon_texture = st_texture_cache_load_gicon (cache,
|
||||
(priv->icon_type != ST_ICON_APPLICATION &&
|
||||
priv->icon_type != ST_ICON_DOCUMENT) ?
|
||||
theme_node : NULL,
|
||||
priv->gicon,
|
||||
priv->icon_size);
|
||||
}
|
||||
else if (priv->icon_name)
|
||||
{
|
||||
priv->icon_texture = st_texture_cache_load_icon_name (cache,
|
||||
theme_node,
|
||||
priv->icon_name,
|
||||
priv->icon_type,
|
||||
priv->icon_size);
|
||||
}
|
||||
if (priv->icon_texture)
|
||||
clutter_actor_set_parent (priv->icon_texture, CLUTTER_ACTOR (icon));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -397,9 +430,16 @@ st_icon_set_icon_name (StIcon *icon,
|
||||
g_free (priv->icon_name);
|
||||
priv->icon_name = g_strdup (icon_name);
|
||||
|
||||
st_icon_update (icon);
|
||||
if (priv->gicon)
|
||||
{
|
||||
g_object_unref (priv->gicon);
|
||||
priv->gicon = NULL;
|
||||
g_object_notify (G_OBJECT (icon), "gicon");
|
||||
}
|
||||
|
||||
g_object_notify (G_OBJECT (icon), "icon-name");
|
||||
|
||||
st_icon_update (icon);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -448,6 +488,55 @@ st_icon_set_icon_type (StIcon *icon,
|
||||
g_object_notify (G_OBJECT (icon), "icon-type");
|
||||
}
|
||||
|
||||
/**
|
||||
* st_icon_get_gicon:
|
||||
* @icon: an icon
|
||||
*
|
||||
* Return value: (transfer none): the override GIcon, if set, or NULL
|
||||
*/
|
||||
GIcon *
|
||||
st_icon_get_gicon (StIcon *icon)
|
||||
{
|
||||
g_return_val_if_fail (ST_IS_ICON (icon), NULL);
|
||||
|
||||
return icon->priv->gicon;
|
||||
}
|
||||
|
||||
/**
|
||||
* st_icon_set_gicon:
|
||||
* @icon: an icon
|
||||
* @gicon: (allow-none): a #GIcon to override :icon-name
|
||||
*/
|
||||
void
|
||||
st_icon_set_gicon (StIcon *icon, GIcon *gicon)
|
||||
{
|
||||
g_return_if_fail (ST_IS_ICON (icon));
|
||||
g_return_if_fail (G_IS_ICON (gicon));
|
||||
|
||||
if (icon->priv->gicon == gicon) /* do nothing */
|
||||
return;
|
||||
|
||||
if (icon->priv->gicon)
|
||||
{
|
||||
g_object_unref (icon->priv->gicon);
|
||||
icon->priv->gicon = NULL;
|
||||
}
|
||||
|
||||
if (gicon)
|
||||
icon->priv->gicon = g_object_ref (gicon);
|
||||
|
||||
if (icon->priv->icon_name)
|
||||
{
|
||||
g_free (icon->priv->icon_name);
|
||||
icon->priv->icon_name = NULL;
|
||||
g_object_notify (G_OBJECT (icon), "icon-name");
|
||||
}
|
||||
|
||||
g_object_notify (G_OBJECT (icon), "gicon");
|
||||
|
||||
st_icon_update (icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_icon_get_icon_size:
|
||||
* @icon: an icon
|
||||
|
@ -29,6 +29,7 @@
|
||||
#define _ST_ICON
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gio/gio.h>
|
||||
#include <st/st-widget.h>
|
||||
|
||||
#include <st/st-types.h>
|
||||
@ -93,6 +94,8 @@ StIconType st_icon_get_icon_type (StIcon *icon);
|
||||
gint st_icon_get_icon_size (StIcon *icon);
|
||||
void st_icon_set_icon_size (StIcon *icon, gint size);
|
||||
|
||||
void st_icon_set_gicon (StIcon *icon, GIcon *gicon);
|
||||
GIcon *st_icon_get_gicon (StIcon *icon);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -1118,6 +1118,8 @@ load_gicon_with_colors (StTextureCache *cache,
|
||||
/**
|
||||
* st_texture_cache_load_gicon:
|
||||
* @cache: The texture cache instance
|
||||
* @theme_node: (allow-none): The #StThemeNode to use for colors, or NULL
|
||||
* if the icon must not be recolored
|
||||
* @icon: the #GIcon to load
|
||||
* @size: Size of themed
|
||||
*
|
||||
@ -1132,10 +1134,11 @@ load_gicon_with_colors (StTextureCache *cache,
|
||||
*/
|
||||
ClutterActor *
|
||||
st_texture_cache_load_gicon (StTextureCache *cache,
|
||||
StThemeNode *theme_node,
|
||||
GIcon *icon,
|
||||
gint size)
|
||||
{
|
||||
return load_gicon_with_colors (cache, icon, size, NULL);
|
||||
return load_gicon_with_colors (cache, icon, size, theme_node ? st_theme_node_get_icon_colors (theme_node) : NULL);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
@ -1328,7 +1331,7 @@ st_texture_cache_load_icon_name (StTextureCache *cache,
|
||||
case ST_ICON_APPLICATION:
|
||||
case ST_ICON_DOCUMENT:
|
||||
themed = g_themed_icon_new (name);
|
||||
texture = st_texture_cache_load_gicon (cache, themed, size);
|
||||
texture = load_gicon_with_colors (cache, themed, size, NULL);
|
||||
g_object_unref (themed);
|
||||
|
||||
return CLUTTER_ACTOR (texture);
|
||||
@ -1345,7 +1348,8 @@ st_texture_cache_load_icon_name (StTextureCache *cache,
|
||||
break;
|
||||
case ST_ICON_FULLCOLOR:
|
||||
themed = g_themed_icon_new_with_default_fallbacks (name);
|
||||
texture = st_texture_cache_load_gicon (cache, themed, size);
|
||||
texture = load_gicon_with_colors (cache, themed, size, NULL);
|
||||
g_object_unref (themed);
|
||||
|
||||
return CLUTTER_ACTOR (texture);
|
||||
break;
|
||||
@ -1693,7 +1697,7 @@ st_texture_cache_load_thumbnail (StTextureCache *cache,
|
||||
if (!g_str_has_prefix (uri, "file://"))
|
||||
{
|
||||
GIcon *icon = icon_for_mimetype (mimetype);
|
||||
return st_texture_cache_load_gicon (cache, icon, size);
|
||||
return st_texture_cache_load_gicon (cache, NULL, icon, size);
|
||||
}
|
||||
|
||||
texture = create_default_texture (cache);
|
||||
@ -1770,7 +1774,7 @@ st_texture_cache_load_recent_thumbnail (StTextureCache *cache,
|
||||
if (!g_str_has_prefix (uri, "file://"))
|
||||
{
|
||||
GIcon *icon = icon_for_recent (info);
|
||||
return st_texture_cache_load_gicon (cache, icon, size);
|
||||
return st_texture_cache_load_gicon (cache, NULL, icon, size);
|
||||
}
|
||||
|
||||
texture = CLUTTER_TEXTURE (clutter_texture_new ());
|
||||
|
@ -85,6 +85,7 @@ ClutterActor *st_texture_cache_load_icon_name (StTextureCache *cache,
|
||||
gint size);
|
||||
|
||||
ClutterActor *st_texture_cache_load_gicon (StTextureCache *cache,
|
||||
StThemeNode *theme_node,
|
||||
GIcon *icon,
|
||||
gint size);
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "st-tooltip.h"
|
||||
|
||||
#include "st-widget.h"
|
||||
#include "st-label.h"
|
||||
#include "st-private.h"
|
||||
|
||||
enum
|
||||
@ -56,7 +57,7 @@ enum
|
||||
|
||||
struct _StTooltipPrivate
|
||||
{
|
||||
ClutterActor *label;
|
||||
StLabel *label;
|
||||
|
||||
gfloat arrow_offset;
|
||||
gboolean actor_below;
|
||||
@ -68,6 +69,10 @@ extern gfloat st_slow_down_factor;
|
||||
|
||||
G_DEFINE_TYPE (StTooltip, st_tooltip, ST_TYPE_WIDGET);
|
||||
|
||||
static void st_tooltip_show (ClutterActor *self);
|
||||
static void st_tooltip_show_all (ClutterActor *self);
|
||||
static void st_tooltip_hide_all (ClutterActor *self);
|
||||
|
||||
static void
|
||||
st_tooltip_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
@ -102,7 +107,7 @@ st_tooltip_get_property (GObject *gobject,
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_LABEL:
|
||||
g_value_set_string (value, clutter_text_get_text (CLUTTER_TEXT (priv->label)));
|
||||
g_value_set_string (value, st_label_get_text (priv->label));
|
||||
break;
|
||||
|
||||
case PROP_TIP_AREA:
|
||||
@ -115,29 +120,6 @@ st_tooltip_get_property (GObject *gobject,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
st_tooltip_style_changed (StWidget *self)
|
||||
{
|
||||
StTooltipPrivate *priv;
|
||||
StThemeNode *theme_node;
|
||||
ClutterColor color;
|
||||
const PangoFontDescription *font;
|
||||
gchar *font_string;
|
||||
|
||||
priv = ST_TOOLTIP (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_tooltip_parent_class)->style_changed (self);
|
||||
}
|
||||
|
||||
static void
|
||||
st_tooltip_get_preferred_width (ClutterActor *self,
|
||||
gfloat for_height,
|
||||
@ -159,13 +141,10 @@ st_tooltip_get_preferred_width (ClutterActor *self,
|
||||
label_height = -1;
|
||||
}
|
||||
|
||||
if (priv->label)
|
||||
{
|
||||
clutter_actor_get_preferred_width (priv->label,
|
||||
label_height,
|
||||
min_width_p,
|
||||
natural_width_p);
|
||||
}
|
||||
clutter_actor_get_preferred_width (CLUTTER_ACTOR (priv->label),
|
||||
label_height,
|
||||
min_width_p,
|
||||
natural_width_p);
|
||||
|
||||
st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p);
|
||||
}
|
||||
@ -182,19 +161,10 @@ st_tooltip_get_preferred_height (ClutterActor *self,
|
||||
|
||||
st_theme_node_adjust_for_width (theme_node, &for_width);
|
||||
|
||||
if (priv->label)
|
||||
{
|
||||
clutter_actor_get_preferred_height (priv->label,
|
||||
for_width,
|
||||
&min_label_h,
|
||||
&natural_label_h);
|
||||
}
|
||||
else
|
||||
{
|
||||
min_label_h = 0;
|
||||
natural_label_h = 0;
|
||||
}
|
||||
|
||||
clutter_actor_get_preferred_height (CLUTTER_ACTOR (priv->label),
|
||||
for_width,
|
||||
&min_label_h,
|
||||
&natural_label_h);
|
||||
if (min_height_p)
|
||||
*min_height_p = min_label_h;
|
||||
|
||||
@ -223,12 +193,9 @@ st_tooltip_allocate (ClutterActor *self,
|
||||
child_box.x2 = (box->x2 - box->x1);
|
||||
child_box.y2 = (box->y2 - box->y1);
|
||||
|
||||
if (priv->label)
|
||||
{
|
||||
child_box = content_box;
|
||||
child_box = content_box;
|
||||
|
||||
clutter_actor_allocate (priv->label, &child_box, flags);
|
||||
}
|
||||
clutter_actor_allocate (CLUTTER_ACTOR (priv->label), &child_box, flags);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -236,7 +203,9 @@ st_tooltip_paint (ClutterActor *self)
|
||||
{
|
||||
StTooltipPrivate *priv = ST_TOOLTIP (self)->priv;
|
||||
|
||||
clutter_actor_paint (priv->label);
|
||||
CLUTTER_ACTOR_CLASS (st_tooltip_parent_class)->paint (self);
|
||||
|
||||
clutter_actor_paint (CLUTTER_ACTOR (priv->label));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -246,7 +215,7 @@ st_tooltip_map (ClutterActor *self)
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_tooltip_parent_class)->map (self);
|
||||
|
||||
clutter_actor_map (priv->label);
|
||||
clutter_actor_map (CLUTTER_ACTOR (priv->label));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -256,7 +225,7 @@ st_tooltip_unmap (ClutterActor *self)
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_tooltip_parent_class)->unmap (self);
|
||||
|
||||
clutter_actor_unmap (priv->label);
|
||||
clutter_actor_unmap (CLUTTER_ACTOR (priv->label));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -266,7 +235,7 @@ st_tooltip_dispose (GObject *self)
|
||||
|
||||
if (priv->label)
|
||||
{
|
||||
clutter_actor_destroy (priv->label);
|
||||
clutter_actor_destroy (CLUTTER_ACTOR (priv->label));
|
||||
priv->label = NULL;
|
||||
}
|
||||
|
||||
@ -278,7 +247,6 @@ st_tooltip_class_init (StTooltipClass *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 (StTooltipPrivate));
|
||||
@ -293,8 +261,9 @@ st_tooltip_class_init (StTooltipClass *klass)
|
||||
actor_class->paint = st_tooltip_paint;
|
||||
actor_class->map = st_tooltip_map;
|
||||
actor_class->unmap = st_tooltip_unmap;
|
||||
|
||||
widget_class->style_changed = st_tooltip_style_changed;
|
||||
actor_class->show = st_tooltip_show;
|
||||
actor_class->show_all = st_tooltip_show_all;
|
||||
actor_class->hide_all = st_tooltip_hide_all;
|
||||
|
||||
pspec = g_param_spec_string ("label",
|
||||
"Label",
|
||||
@ -315,11 +284,7 @@ st_tooltip_init (StTooltip *tooltip)
|
||||
{
|
||||
tooltip->priv = ST_TOOLTIP_GET_PRIVATE (tooltip);
|
||||
|
||||
tooltip->priv->label = g_object_new (CLUTTER_TYPE_TEXT,
|
||||
"line-alignment", PANGO_ALIGN_CENTER,
|
||||
"ellipsize", PANGO_ELLIPSIZE_END,
|
||||
"use-markup", TRUE,
|
||||
NULL);
|
||||
tooltip->priv->label = ST_LABEL (st_label_new (NULL));
|
||||
|
||||
tooltip->priv->tip_area = NULL;
|
||||
|
||||
@ -417,7 +382,7 @@ st_tooltip_get_label (StTooltip *tooltip)
|
||||
{
|
||||
g_return_val_if_fail (ST_IS_TOOLTIP (tooltip), NULL);
|
||||
|
||||
return clutter_text_get_text (CLUTTER_TEXT (tooltip->priv->label));
|
||||
return st_label_get_text (tooltip->priv->label);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -437,32 +402,18 @@ st_tooltip_set_label (StTooltip *tooltip,
|
||||
|
||||
priv = tooltip->priv;
|
||||
|
||||
clutter_text_set_text (CLUTTER_TEXT (priv->label), text);
|
||||
st_label_set_text (priv->label, text);
|
||||
|
||||
g_object_notify (G_OBJECT (tooltip), "label");
|
||||
}
|
||||
|
||||
/**
|
||||
* st_tooltip_show:
|
||||
* @tooltip: a #StTooltip
|
||||
*
|
||||
* Show the tooltip relative to the associated widget.
|
||||
*/
|
||||
void
|
||||
st_tooltip_show (StTooltip *tooltip)
|
||||
static void
|
||||
st_tooltip_show (ClutterActor *self)
|
||||
{
|
||||
StTooltipPrivate *priv;
|
||||
StTooltip *tooltip = ST_TOOLTIP (self);
|
||||
ClutterActor *parent;
|
||||
ClutterActor *stage;
|
||||
ClutterActor *self = CLUTTER_ACTOR (tooltip);
|
||||
ClutterAnimation *animation;
|
||||
|
||||
/* make sure we're not currently already animating (e.g. hiding) */
|
||||
animation = clutter_actor_get_animation (CLUTTER_ACTOR (tooltip));
|
||||
if (animation)
|
||||
clutter_animation_completed (animation);
|
||||
|
||||
priv = tooltip->priv;
|
||||
parent = clutter_actor_get_parent (self);
|
||||
stage = clutter_actor_get_stage (self);
|
||||
|
||||
@ -491,59 +442,22 @@ st_tooltip_show (StTooltip *tooltip)
|
||||
|
||||
/* finally show the tooltip... */
|
||||
CLUTTER_ACTOR_CLASS (st_tooltip_parent_class)->show (self);
|
||||
|
||||
/* and give it some bounce! */
|
||||
g_object_set (G_OBJECT (self),
|
||||
"scale-center-x", priv->arrow_offset,
|
||||
"scale-center-y", (priv->actor_below) ? clutter_actor_get_height (self) : 0,
|
||||
NULL);
|
||||
clutter_actor_set_scale (self, 0.0, 0.0);
|
||||
clutter_actor_animate (self, CLUTTER_EASE_OUT_ELASTIC,
|
||||
500,
|
||||
"scale-x", 1.0,
|
||||
"scale-y", 1.0,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
st_tooltip_hide_complete (ClutterAnimation *animation,
|
||||
ClutterActor *actor)
|
||||
st_tooltip_show_all (ClutterActor *self)
|
||||
{
|
||||
CLUTTER_ACTOR_CLASS (st_tooltip_parent_class)->hide (actor);
|
||||
g_signal_handlers_disconnect_by_func (actor,
|
||||
st_tooltip_hide_complete,
|
||||
actor);
|
||||
CLUTTER_ACTOR_CLASS (st_tooltip_parent_class)->show_all (self);
|
||||
|
||||
clutter_actor_show_all (CLUTTER_ACTOR (ST_TOOLTIP (self)->priv->label));
|
||||
}
|
||||
|
||||
/**
|
||||
* st_tooltip_hide:
|
||||
* @tooltip: a #StTooltip
|
||||
*
|
||||
* Hide the tooltip
|
||||
*/
|
||||
void
|
||||
st_tooltip_hide (StTooltip *tooltip)
|
||||
static void
|
||||
st_tooltip_hide_all (ClutterActor *self)
|
||||
{
|
||||
ClutterAnimation *animation;
|
||||
CLUTTER_ACTOR_CLASS (st_tooltip_parent_class)->hide_all (self);
|
||||
|
||||
g_return_if_fail (ST_TOOLTIP (tooltip));
|
||||
|
||||
/* make sure we're not currently already animating (e.g. hiding) */
|
||||
animation = clutter_actor_get_animation (CLUTTER_ACTOR (tooltip));
|
||||
if (animation)
|
||||
clutter_animation_completed (animation);
|
||||
|
||||
g_object_set (G_OBJECT (tooltip),
|
||||
"scale-center-x", tooltip->priv->arrow_offset,
|
||||
NULL);
|
||||
animation =
|
||||
clutter_actor_animate (CLUTTER_ACTOR (tooltip), CLUTTER_EASE_IN_SINE,
|
||||
(guint)(150 * st_slow_down_factor),
|
||||
"scale-x", 0.0,
|
||||
"scale-y", 0.0,
|
||||
NULL);
|
||||
g_signal_connect (animation, "completed",
|
||||
G_CALLBACK (st_tooltip_hide_complete), tooltip);
|
||||
clutter_actor_hide_all (CLUTTER_ACTOR (ST_TOOLTIP (self)->priv->label));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -48,14 +48,14 @@ typedef struct _StTooltipClass StTooltipClass;
|
||||
struct _StTooltip
|
||||
{
|
||||
/*< private >*/
|
||||
StBin parent_instance;
|
||||
StWidget parent_instance;
|
||||
|
||||
StTooltipPrivate *priv;
|
||||
};
|
||||
|
||||
struct _StTooltipClass
|
||||
{
|
||||
StBinClass parent_class;
|
||||
StWidgetClass parent_class;
|
||||
};
|
||||
|
||||
GType st_tooltip_get_type (void) G_GNUC_CONST;
|
||||
@ -63,8 +63,6 @@ GType st_tooltip_get_type (void) G_GNUC_CONST;
|
||||
G_CONST_RETURN gchar *st_tooltip_get_label (StTooltip *tooltip);
|
||||
void st_tooltip_set_label (StTooltip *tooltip,
|
||||
const gchar *text);
|
||||
void st_tooltip_show (StTooltip *tooltip);
|
||||
void st_tooltip_hide (StTooltip *tooltip);
|
||||
|
||||
void st_tooltip_set_tip_area (StTooltip *tooltip,
|
||||
const ClutterGeometry *area);
|
||||
|
@ -663,7 +663,7 @@ st_widget_hide (ClutterActor *actor)
|
||||
|
||||
/* hide the tooltip, if there is one */
|
||||
if (widget->priv->tooltip)
|
||||
st_tooltip_hide (ST_TOOLTIP (widget->priv->tooltip));
|
||||
clutter_actor_hide (CLUTTER_ACTOR (widget->priv->tooltip));
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_widget_parent_class)->hide (actor);
|
||||
}
|
||||
@ -1534,7 +1534,7 @@ st_widget_show_tooltip (StWidget *widget)
|
||||
if (widget->priv->tooltip)
|
||||
{
|
||||
st_tooltip_set_tip_area (widget->priv->tooltip, &area);
|
||||
st_tooltip_show (widget->priv->tooltip);
|
||||
clutter_actor_show_all (CLUTTER_ACTOR (widget->priv->tooltip));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1551,7 +1551,7 @@ st_widget_hide_tooltip (StWidget *widget)
|
||||
g_return_if_fail (ST_IS_WIDGET (widget));
|
||||
|
||||
if (widget->priv->tooltip)
|
||||
st_tooltip_hide (widget->priv->tooltip);
|
||||
clutter_actor_hide (CLUTTER_ACTOR (widget->priv->tooltip));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,13 +60,14 @@ fi
|
||||
# dbus-glib, expat, GL, gnome-menus, gstreamer, libffi,
|
||||
# libjasper, libjpeg, libpng, libpulse, libtiff, libwnck,
|
||||
# libxklavier, libxml2, ORBit2, pam, python, readline,
|
||||
# spidermonkey ({mozilla,firefox,xulrunner}-js), startup-notification
|
||||
# xdamage, icon-naming-utils, libtool-ltdl, libvorbis
|
||||
# spidermonkey ({mozilla,firefox,xulrunner}-js), startup-notification,
|
||||
# xdamage, icon-naming-utils, upower, libtool-ltdl, libvorbis,
|
||||
# libgcrypt, libtasn1
|
||||
#
|
||||
# Non-devel packages needed by gnome-shell and its deps:
|
||||
# glxinfo, gstreamer-plugins-base, gstreamer-plugins-good,
|
||||
# gvfs, python, pygobject, gnome-python (gconf), gnome-terminal*,
|
||||
# icon-naming-utils, Xephyr*, zenity
|
||||
# icon-naming-utils, Xephyr*, zenity, libtasn1-tools
|
||||
#
|
||||
# (*) only needed for --xephyr
|
||||
|
||||
@ -117,7 +118,8 @@ if test "x$system" = xFedora ; then
|
||||
libXdamage-devel libcroco-devel libxml2-devel gstreamer-devel
|
||||
gstreamer-plugins-base gstreamer-plugins-good glx-utils expat-devel
|
||||
startup-notification-devel xorg-x11-server-Xephyr gnome-terminal zenity
|
||||
icon-naming-utils libtool-ltdl-devel libvorbis-devel libxklavier-devel
|
||||
icon-naming-utils upower-devel libtool-ltdl-devel libvorbis-devel
|
||||
libxklavier-devel libgcrypt-devel libtasn1-devel libtasn1-tools
|
||||
"
|
||||
|
||||
if expr $version \>= 14 > /dev/null ; then
|
||||
|
@ -191,6 +191,59 @@
|
||||
</dependencies>
|
||||
</autotools>
|
||||
|
||||
<autotools id="gnome-keyring">
|
||||
<branch repo="git.gnome.org" module="gnome-keyring"/>
|
||||
<dependencies>
|
||||
<dep package="glib"/>
|
||||
</dependencies>
|
||||
</autotools>
|
||||
|
||||
<autotools id="libnotify">
|
||||
<branch repo="git.gnome.org" module="libnotify"/>
|
||||
<dependencies>
|
||||
<dep package="gtk3"/>
|
||||
</dependencies>
|
||||
</autotools>
|
||||
|
||||
<autotools id="libgnomekbd">
|
||||
<branch repo="git.gnome.org" module="libgnomekbd"/>
|
||||
<dependencies>
|
||||
<dep package="gtk3"/>
|
||||
</dependencies>
|
||||
</autotools>
|
||||
|
||||
<autotools id="gnome-settings-daemon">
|
||||
<branch repo="git.gnome.org" module="gnome-settings-daemon"/>
|
||||
<dependencies>
|
||||
<dep package="libnotify"/>
|
||||
<dep package="gnome-desktop-3"/>
|
||||
</dependencies>
|
||||
</autotools>
|
||||
|
||||
<autotools id="gnome-control-center">
|
||||
<branch repo="git.gnome.org" module="gnome-control-center"/>
|
||||
<dependencies>
|
||||
<dep package="gtk3"/>
|
||||
<dep package="libcanberra"/>
|
||||
<dep package="gnome-desktop-3"/>
|
||||
<dep package="gnome-settings-daemon"/>
|
||||
</dependencies>
|
||||
</autotools>
|
||||
|
||||
<autotools id="gnome-power-manager">
|
||||
<branch repo="git.gnome.org" module="gnome-power-manager" />
|
||||
<dependencies>
|
||||
<dep package="gtk3"/>
|
||||
<dep package="glib"/>
|
||||
<dep package="gconf"/>
|
||||
<dep package="cairo"/>
|
||||
<dep package="libnotify"/>
|
||||
<dep package="gnome-keyring"/>
|
||||
<dep package="libcanberra"/>
|
||||
<dep package="gnome-control-center"/>
|
||||
</dependencies>
|
||||
</autotools>
|
||||
|
||||
<autotools id="gnome-shell">
|
||||
<branch repo="git.gnome.org" module="gnome-shell"/>
|
||||
<dependencies>
|
||||
@ -214,9 +267,7 @@
|
||||
change their ~/.jhbuildrc -->
|
||||
<metamodule id="gnome-shell-using-gir-repository">
|
||||
<dependencies>
|
||||
<dep package="librsvg"/>
|
||||
<dep package="gnome-themes-standard"/>
|
||||
<dep package="gnome-shell"/>
|
||||
<dep package="gnome-shell-full"/>
|
||||
</dependencies>
|
||||
</metamodule>
|
||||
|
||||
@ -225,6 +276,7 @@
|
||||
<dep package="librsvg"/>
|
||||
<dep package="gnome-themes-standard"/>
|
||||
<dep package="gnome-shell"/>
|
||||
<dep package="gnome-power-manager"/>
|
||||
</dependencies>
|
||||
</metamodule>
|
||||
|
||||
@ -240,6 +292,14 @@
|
||||
</suggests>
|
||||
</tarball>
|
||||
|
||||
<autotools id="libnotify">
|
||||
<branch repo="git.gnome.org" module="libnotify"/>
|
||||
<dependencies>
|
||||
<dep package="glib"/>
|
||||
<dep package="gtk3"/>
|
||||
</dependencies>
|
||||
</autotools>
|
||||
|
||||
<autotools id="gnome-settings-daemon">
|
||||
<branch repo="git.gnome.org" module="gnome-settings-daemon"/>
|
||||
<dependencies>
|
||||
@ -247,6 +307,7 @@
|
||||
<dep package="gtk3"/>
|
||||
<dep package="gnome-desktop-3"/>
|
||||
<dep package="libgnomekbd"/>
|
||||
<dep package="libnotify" />
|
||||
<dep package="polkit"/>
|
||||
</dependencies>
|
||||
</autotools>
|
||||
|
Loading…
Reference in New Issue
Block a user