mirror of
https://github.com/elementary/gala.git
synced 2024-09-11 07:05:30 +03:00
👕 Lint lib directory with vala-lint (#607)
This commit is contained in:
parent
50694796d4
commit
49d1d8ffab
@ -15,16 +15,14 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
namespace Gala
|
||||
{
|
||||
namespace Gala {
|
||||
/**
|
||||
* Implement this interface on your {@link Plugin} class if you want to
|
||||
* replace a component like the window overview or the multitasking view.
|
||||
* It allows gala to hook up functionality like hotcorners and dbus
|
||||
* invocation of your component.
|
||||
*/
|
||||
public interface ActivatableComponent : Object
|
||||
{
|
||||
public interface ActivatableComponent : Object {
|
||||
/**
|
||||
* The component was requested to be opened.
|
||||
*
|
||||
@ -48,4 +46,3 @@ namespace Gala
|
||||
public abstract bool is_opened ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,7 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
namespace Gala
|
||||
{
|
||||
namespace Gala {
|
||||
[CCode (has_type_id = false)]
|
||||
public enum AnimationDuration {
|
||||
// Duration of the open animation
|
||||
|
@ -15,10 +15,8 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
namespace Gala
|
||||
{
|
||||
public enum PluginFunction
|
||||
{
|
||||
namespace Gala {
|
||||
public enum PluginFunction {
|
||||
ADDITION,
|
||||
WINDOW_SWITCHER,
|
||||
DESKTOP,
|
||||
@ -26,8 +24,7 @@ namespace Gala
|
||||
WINDOW_OVERVIEW
|
||||
}
|
||||
|
||||
public enum LoadPriority
|
||||
{
|
||||
public enum LoadPriority {
|
||||
/**
|
||||
* Have your plugin loaded immediately once gala has started
|
||||
*/
|
||||
@ -39,8 +36,7 @@ namespace Gala
|
||||
DEFERRED
|
||||
}
|
||||
|
||||
public struct PluginInfo
|
||||
{
|
||||
public struct PluginInfo {
|
||||
string name;
|
||||
string author;
|
||||
|
||||
@ -77,8 +73,7 @@ namespace Gala
|
||||
* The plugin_type field has to be the type of your plugin class derived
|
||||
* from this class.
|
||||
*/
|
||||
public abstract class Plugin : Object
|
||||
{
|
||||
public abstract class Plugin : Object {
|
||||
/**
|
||||
* Emitted when update_region is called. Mainly for internal purposes.
|
||||
*/
|
||||
@ -152,8 +147,7 @@ namespace Gala
|
||||
*
|
||||
* @param actor The actor to be tracked
|
||||
*/
|
||||
public void track_actor (Clutter.Actor actor)
|
||||
{
|
||||
public void track_actor (Clutter.Actor actor) {
|
||||
tracked_actors.prepend (actor);
|
||||
actor.allocation_changed.connect (actor_allocation_changed);
|
||||
|
||||
@ -166,8 +160,7 @@ namespace Gala
|
||||
*
|
||||
* @param actor The actor to stop listening the changes on
|
||||
*/
|
||||
public void untrack_actor (Clutter.Actor actor)
|
||||
{
|
||||
public void untrack_actor (Clutter.Actor actor) {
|
||||
tracked_actors.remove (actor);
|
||||
actor.allocation_changed.disconnect (actor_allocation_changed);
|
||||
}
|
||||
@ -180,8 +173,7 @@ namespace Gala
|
||||
* after setting freeze_track back to false after an animation to make the
|
||||
* wm aware of the new position of the actor in question.
|
||||
*/
|
||||
public void update_region ()
|
||||
{
|
||||
public void update_region () {
|
||||
var has_custom = custom_region != null;
|
||||
var len = tracked_actors.length () + (has_custom ? custom_region.length : 0);
|
||||
|
||||
@ -210,11 +202,9 @@ namespace Gala
|
||||
region_changed ();
|
||||
}
|
||||
|
||||
private void actor_allocation_changed (Clutter.ActorBox box, Clutter.AllocationFlags f)
|
||||
{
|
||||
private void actor_allocation_changed (Clutter.ActorBox box, Clutter.AllocationFlags f) {
|
||||
if (!freeze_track)
|
||||
update_region ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,10 +15,8 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
namespace Gala
|
||||
{
|
||||
public class Utils
|
||||
{
|
||||
namespace Gala {
|
||||
public class Utils {
|
||||
// Cache xid:pixbuf and icon:pixbuf pairs to provide a faster way aquiring icons
|
||||
static HashTable<string, Gdk.Pixbuf> xid_pixbuf_cache;
|
||||
static HashTable<string, Gdk.Pixbuf> icon_pixbuf_cache;
|
||||
@ -27,21 +25,18 @@ namespace Gala
|
||||
static Gdk.Pixbuf? close_pixbuf = null;
|
||||
static Gdk.Pixbuf? resize_pixbuf = null;
|
||||
|
||||
static construct
|
||||
{
|
||||
static construct {
|
||||
xid_pixbuf_cache = new HashTable<string, Gdk.Pixbuf> (str_hash, str_equal);
|
||||
icon_pixbuf_cache = new HashTable<string, Gdk.Pixbuf> (str_hash, str_equal);
|
||||
}
|
||||
|
||||
Utils ()
|
||||
{
|
||||
Utils () {
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean icon caches
|
||||
*/
|
||||
static void clean_icon_cache (uint32[] xids)
|
||||
{
|
||||
static void clean_icon_cache (uint32[] xids) {
|
||||
var list = xid_pixbuf_cache.get_keys ();
|
||||
var pixbuf_list = icon_pixbuf_cache.get_values ();
|
||||
var icon_list = icon_pixbuf_cache.get_keys ();
|
||||
@ -67,8 +62,7 @@ namespace Gala
|
||||
*
|
||||
* @param xids The xids of the window that no longer need icons
|
||||
*/
|
||||
public static void request_clean_icon_cache (uint32[] xids)
|
||||
{
|
||||
public static void request_clean_icon_cache (uint32[] xids) {
|
||||
if (cache_clear_timeout > 0)
|
||||
GLib.Source.remove (cache_clear_timeout);
|
||||
|
||||
@ -91,8 +85,12 @@ namespace Gala
|
||||
* @param ignore_cache Should not be necessary in most cases, if you care about the icon
|
||||
* being loaded correctly, you should consider using the WindowIcon class
|
||||
*/
|
||||
public static Gdk.Pixbuf get_icon_for_window (Meta.Window window, int size, int scale = 1, bool ignore_cache = false)
|
||||
{
|
||||
public static Gdk.Pixbuf get_icon_for_window (
|
||||
Meta.Window window,
|
||||
int size,
|
||||
int scale = 1,
|
||||
bool ignore_cache = false
|
||||
) {
|
||||
return get_icon_for_xid ((uint32)window.get_xwindow (), size, scale, ignore_cache);
|
||||
}
|
||||
|
||||
@ -101,8 +99,7 @@ namespace Gala
|
||||
*
|
||||
* @see get_icon_for_window
|
||||
*/
|
||||
public static Gdk.Pixbuf get_icon_for_xid (uint32 xid, int size, int scale = 1, bool ignore_cache = false)
|
||||
{
|
||||
public static Gdk.Pixbuf get_icon_for_xid (uint32 xid, int size, int scale = 1, bool ignore_cache = false) {
|
||||
Gdk.Pixbuf? result = null;
|
||||
var xid_key = "%u::%i".printf (xid, size);
|
||||
|
||||
@ -122,9 +119,12 @@ namespace Gala
|
||||
*
|
||||
* @see get_icon_for_window
|
||||
*/
|
||||
static Gdk.Pixbuf get_icon_for_application (Bamf.Application? app, int size, int scale = 1,
|
||||
bool ignore_cache = false)
|
||||
{
|
||||
static Gdk.Pixbuf get_icon_for_application (
|
||||
Bamf.Application? app,
|
||||
int size,
|
||||
int scale = 1,
|
||||
bool ignore_cache = false
|
||||
) {
|
||||
Gdk.Pixbuf? image = null;
|
||||
bool not_cached = false;
|
||||
|
||||
@ -185,8 +185,7 @@ namespace Gala
|
||||
* @param workspace The workspace on which to find the window
|
||||
* @param backward Whether to get the previous one instead
|
||||
*/
|
||||
public static Meta.Window get_next_window (Meta.Workspace workspace, bool backward = false)
|
||||
{
|
||||
public static Meta.Window get_next_window (Meta.Workspace workspace, bool backward = false) {
|
||||
var screen = workspace.get_screen ();
|
||||
var display = screen.get_display ();
|
||||
|
||||
@ -205,13 +204,13 @@ namespace Gala
|
||||
*
|
||||
* @param workspace The workspace on which to count the windows
|
||||
*/
|
||||
public static uint get_n_windows (Meta.Workspace workspace)
|
||||
{
|
||||
public static uint get_n_windows (Meta.Workspace workspace) {
|
||||
var n = 0;
|
||||
foreach (weak Meta.Window window in workspace.list_windows ()) {
|
||||
if (window.on_all_workspaces)
|
||||
continue;
|
||||
if (window.window_type == Meta.WindowType.NORMAL ||
|
||||
if (
|
||||
window.window_type == Meta.WindowType.NORMAL ||
|
||||
window.window_type == Meta.WindowType.DIALOG ||
|
||||
window.window_type == Meta.WindowType.MODAL_DIALOG)
|
||||
n ++;
|
||||
@ -229,8 +228,11 @@ namespace Gala
|
||||
*
|
||||
* @return A copy of the actor at that time or %NULL
|
||||
*/
|
||||
public static Clutter.Actor? get_window_actor_snapshot (Meta.WindowActor actor, Meta.Rectangle inner_rect, Meta.Rectangle outer_rect)
|
||||
{
|
||||
public static Clutter.Actor? get_window_actor_snapshot (
|
||||
Meta.WindowActor actor,
|
||||
Meta.Rectangle inner_rect,
|
||||
Meta.Rectangle outer_rect
|
||||
) {
|
||||
var texture = actor.get_texture () as Meta.ShapedTexture;
|
||||
|
||||
if (texture == null)
|
||||
@ -268,16 +270,14 @@ namespace Gala
|
||||
*
|
||||
* @param screen The screen to flash, if necessary
|
||||
*/
|
||||
public static void bell (Meta.Screen screen)
|
||||
{
|
||||
public static void bell (Meta.Screen screen) {
|
||||
if (Meta.Prefs.bell_is_audible ())
|
||||
Gdk.beep ();
|
||||
else
|
||||
screen.get_display ().get_compositor ().flash_screen (screen);
|
||||
}
|
||||
|
||||
public static int get_ui_scaling_factor ()
|
||||
{
|
||||
public static int get_ui_scaling_factor () {
|
||||
#if HAS_MUTTER326
|
||||
return Meta.Backend.get_backend ().get_settings ().get_ui_scaling_factor ();
|
||||
#else
|
||||
@ -291,12 +291,16 @@ namespace Gala
|
||||
*
|
||||
* @return the close button pixbuf or null if it failed to load
|
||||
*/
|
||||
public static Gdk.Pixbuf? get_close_button_pixbuf ()
|
||||
{
|
||||
public static Gdk.Pixbuf? get_close_button_pixbuf () {
|
||||
var height = 36 * Utils.get_ui_scaling_factor ();
|
||||
if (close_pixbuf == null || close_pixbuf.height != height) {
|
||||
try {
|
||||
close_pixbuf = new Gdk.Pixbuf.from_resource_at_scale (Config.RESOURCEPATH + "/buttons/close.svg", -1, height, true);
|
||||
close_pixbuf = new Gdk.Pixbuf.from_resource_at_scale (
|
||||
Config.RESOURCEPATH + "/buttons/close.svg",
|
||||
-1,
|
||||
height,
|
||||
true
|
||||
);
|
||||
} catch (Error e) {
|
||||
warning (e.message);
|
||||
return null;
|
||||
@ -311,8 +315,7 @@ namespace Gala
|
||||
*
|
||||
* @return The close button actor
|
||||
*/
|
||||
public static Clutter.Actor create_close_button ()
|
||||
{
|
||||
public static Clutter.Actor create_close_button () {
|
||||
var texture = new Clutter.Texture ();
|
||||
var pixbuf = get_close_button_pixbuf ();
|
||||
|
||||
@ -341,13 +344,17 @@ namespace Gala
|
||||
*
|
||||
* @return the close button pixbuf or null if it failed to load
|
||||
*/
|
||||
public static Gdk.Pixbuf? get_resize_button_pixbuf ()
|
||||
{
|
||||
public static Gdk.Pixbuf? get_resize_button_pixbuf () {
|
||||
var height = 36 * Utils.get_ui_scaling_factor ();
|
||||
if (resize_pixbuf == null || resize_pixbuf.height != height) {
|
||||
var scale = Utils.get_ui_scaling_factor ();
|
||||
try {
|
||||
resize_pixbuf = new Gdk.Pixbuf.from_resource_at_scale (Config.RESOURCEPATH + "/buttons/resize.svg", -1, height, true);
|
||||
resize_pixbuf = new Gdk.Pixbuf.from_resource_at_scale (
|
||||
Config.RESOURCEPATH + "/buttons/resize.svg",
|
||||
-1,
|
||||
height,
|
||||
true
|
||||
);
|
||||
} catch (Error e) {
|
||||
warning (e.message);
|
||||
return null;
|
||||
@ -362,8 +369,7 @@ namespace Gala
|
||||
*
|
||||
* @return The resize button actor
|
||||
*/
|
||||
public static Clutter.Actor create_resize_button ()
|
||||
{
|
||||
public static Clutter.Actor create_resize_button () {
|
||||
var texture = new Clutter.Texture ();
|
||||
var pixbuf = get_resize_button_pixbuf ();
|
||||
|
||||
@ -388,8 +394,7 @@ namespace Gala
|
||||
}
|
||||
|
||||
static Gtk.CssProvider gala_css = null;
|
||||
public static unowned Gtk.CssProvider? get_gala_css ()
|
||||
{
|
||||
public static unowned Gtk.CssProvider? get_gala_css () {
|
||||
if (gala_css == null) {
|
||||
gala_css = new Gtk.CssProvider ();
|
||||
gala_css.load_from_resource ("/io/elementary/desktop/gala/gala.css");
|
||||
|
@ -15,19 +15,16 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
namespace Gala
|
||||
{
|
||||
namespace Gala {
|
||||
/**
|
||||
* Creates a new ClutterTexture with an icon for the window at the given size.
|
||||
* This is recommended way to grab an icon for a window as this method will make
|
||||
* sure the icon is updated if it becomes available at a later point.
|
||||
*/
|
||||
public class WindowIcon : Clutter.Texture
|
||||
{
|
||||
public class WindowIcon : Clutter.Texture {
|
||||
static Bamf.Matcher matcher;
|
||||
|
||||
static construct
|
||||
{
|
||||
static construct {
|
||||
matcher = Bamf.Matcher.get_default ();
|
||||
}
|
||||
|
||||
@ -67,16 +64,14 @@ namespace Gala
|
||||
* @param scale The desired scale of the icon
|
||||
* @param destroy_on_unmanaged see destroy_on_unmanaged property
|
||||
*/
|
||||
public WindowIcon (Meta.Window window, int icon_size, int scale = 1, bool destroy_on_unmanaged = false)
|
||||
{
|
||||
public WindowIcon (Meta.Window window, int icon_size, int scale = 1, bool destroy_on_unmanaged = false) {
|
||||
Object (window: window,
|
||||
icon_size: icon_size,
|
||||
destroy_on_unmanaged: destroy_on_unmanaged,
|
||||
scale: scale);
|
||||
}
|
||||
|
||||
construct
|
||||
{
|
||||
construct {
|
||||
width = icon_size * scale;
|
||||
height = icon_size * scale;
|
||||
xid = (uint32) window.get_xwindow ();
|
||||
@ -93,14 +88,12 @@ namespace Gala
|
||||
update_texture (true);
|
||||
}
|
||||
|
||||
~WindowIcon ()
|
||||
{
|
||||
~WindowIcon () {
|
||||
if (!loaded)
|
||||
matcher.view_opened.disconnect (retry_load);
|
||||
}
|
||||
|
||||
void retry_load (Bamf.View view)
|
||||
{
|
||||
void retry_load (Bamf.View view) {
|
||||
var app = matcher.get_application_for_xid (xid);
|
||||
|
||||
// retry only once
|
||||
@ -113,8 +106,7 @@ namespace Gala
|
||||
update_texture (false);
|
||||
}
|
||||
|
||||
void update_texture (bool initial)
|
||||
{
|
||||
void update_texture (bool initial) {
|
||||
var pixbuf = Gala.Utils.get_icon_for_xid (xid, icon_size, scale, !initial);
|
||||
|
||||
try {
|
||||
@ -124,8 +116,7 @@ namespace Gala
|
||||
} catch (Error e) {}
|
||||
}
|
||||
|
||||
void unmanaged (Meta.Window window)
|
||||
{
|
||||
void unmanaged (Meta.Window window) {
|
||||
destroy ();
|
||||
}
|
||||
}
|
||||
|
@ -15,10 +15,8 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
namespace Gala
|
||||
{
|
||||
public enum ActionType
|
||||
{
|
||||
namespace Gala {
|
||||
public enum ActionType {
|
||||
NONE = 0,
|
||||
SHOW_WORKSPACE_VIEW,
|
||||
MAXIMIZE_CURRENT,
|
||||
@ -38,8 +36,7 @@ namespace Gala
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum WindowFlags
|
||||
{
|
||||
public enum WindowFlags {
|
||||
NONE = 0,
|
||||
CAN_MINIMIZE,
|
||||
CAN_MAXIMIZE,
|
||||
@ -60,8 +57,7 @@ namespace Gala
|
||||
* A minimal class mostly used to identify your call to {@link WindowManager.push_modal} and used
|
||||
* to end your modal mode again with {@link WindowManager.pop_modal}
|
||||
*/
|
||||
public class ModalProxy : Object
|
||||
{
|
||||
public class ModalProxy : Object {
|
||||
/**
|
||||
* A function which is called whenever a keybinding is pressed. If you supply a custom
|
||||
* one you can filter out those that'd you like to be passed through and block all others.
|
||||
@ -70,21 +66,18 @@ namespace Gala
|
||||
*/
|
||||
public KeybindingFilter? keybinding_filter { get; owned set; default = () => true; }
|
||||
|
||||
public ModalProxy ()
|
||||
{
|
||||
public ModalProxy () {
|
||||
}
|
||||
|
||||
/**
|
||||
* Small utility to allow all keybindings
|
||||
*/
|
||||
public void allow_all_keybindings ()
|
||||
{
|
||||
public void allow_all_keybindings () {
|
||||
keybinding_filter = null;
|
||||
}
|
||||
}
|
||||
|
||||
public interface WindowManager : Meta.Plugin
|
||||
{
|
||||
public interface WindowManager : Meta.Plugin {
|
||||
/**
|
||||
* This is the container you'll most likely want to add your component to. It wraps
|
||||
* every other container listed in this interface and is a direct child of the stage.
|
||||
|
Loading…
Reference in New Issue
Block a user