2008-10-31 11:20:54 -04:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
2008-10-31 00:22:44 -04:00
|
|
|
#include "shell-global.h"
|
|
|
|
|
|
|
|
struct _ShellGlobal {
|
|
|
|
GObject parent;
|
|
|
|
|
2008-10-31 11:20:54 -04:00
|
|
|
MutterPlugin *plugin;
|
2008-10-31 00:22:44 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _ShellGlobalClass {
|
|
|
|
GObjectClass parent_class;
|
|
|
|
};
|
|
|
|
|
2008-10-31 11:20:54 -04:00
|
|
|
enum {
|
|
|
|
PROP_0,
|
|
|
|
|
|
|
|
PROP_OVERLAY_GROUP,
|
|
|
|
PROP_SCREEN_WIDTH,
|
2008-10-31 14:04:38 -04:00
|
|
|
PROP_SCREEN_HEIGHT,
|
|
|
|
PROP_STAGE
|
2008-10-31 11:20:54 -04:00
|
|
|
};
|
|
|
|
|
2008-10-31 00:22:44 -04:00
|
|
|
G_DEFINE_TYPE(ShellGlobal, shell_global, G_TYPE_OBJECT);
|
|
|
|
|
2008-10-31 11:20:54 -04:00
|
|
|
static void
|
|
|
|
shell_global_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
|
|
|
|
shell_global_get_property(GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
ShellGlobal *global = SHELL_GLOBAL (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_OVERLAY_GROUP:
|
|
|
|
g_value_set_object (value, mutter_plugin_get_overlay_group (global->plugin));
|
|
|
|
break;
|
|
|
|
case PROP_SCREEN_WIDTH:
|
|
|
|
{
|
|
|
|
int width, height;
|
|
|
|
|
|
|
|
mutter_plugin_query_screen_size (global->plugin, &width, &height);
|
|
|
|
g_value_set_int (value, width);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PROP_SCREEN_HEIGHT:
|
|
|
|
{
|
|
|
|
int width, height;
|
|
|
|
|
|
|
|
mutter_plugin_query_screen_size (global->plugin, &width, &height);
|
|
|
|
g_value_set_int (value, height);
|
|
|
|
}
|
|
|
|
break;
|
2008-10-31 14:04:38 -04:00
|
|
|
case PROP_STAGE:
|
|
|
|
g_value_set_object (value, mutter_plugin_get_stage (global->plugin));
|
|
|
|
break;
|
2008-10-31 11:20:54 -04:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-31 00:22:44 -04:00
|
|
|
static void
|
|
|
|
shell_global_init(ShellGlobal *global)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-10-31 11:20:54 -04:00
|
|
|
shell_global_class_init (ShellGlobalClass *klass)
|
2008-10-31 00:22:44 -04:00
|
|
|
{
|
2008-10-31 11:20:54 -04:00
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
gobject_class->get_property = shell_global_get_property;
|
|
|
|
gobject_class->set_property = shell_global_set_property;
|
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_OVERLAY_GROUP,
|
|
|
|
g_param_spec_object ("overlay-group",
|
|
|
|
"Overlay Group",
|
|
|
|
"Actor holding objects that appear above the desktop contents",
|
|
|
|
CLUTTER_TYPE_ACTOR,
|
|
|
|
G_PARAM_READABLE));
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_SCREEN_WIDTH,
|
|
|
|
g_param_spec_int ("screen-width",
|
|
|
|
"Screen Width",
|
|
|
|
"Screen width, in pixels",
|
|
|
|
0, G_MAXINT, 1,
|
|
|
|
G_PARAM_READABLE));
|
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_SCREEN_HEIGHT,
|
|
|
|
g_param_spec_int ("screen-height",
|
|
|
|
"Screen Height",
|
|
|
|
"Screen height, in pixels",
|
|
|
|
0, G_MAXINT, 1,
|
|
|
|
G_PARAM_READABLE));
|
2008-10-31 14:04:38 -04:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_STAGE,
|
|
|
|
g_param_spec_object ("stage",
|
|
|
|
"Stage",
|
|
|
|
"Stage holding the desktop scene graph",
|
|
|
|
CLUTTER_TYPE_ACTOR,
|
|
|
|
G_PARAM_READABLE));
|
2008-10-31 00:22:44 -04:00
|
|
|
}
|
|
|
|
|
2008-10-31 14:24:29 -04:00
|
|
|
/**
|
|
|
|
* shell_global_get:
|
|
|
|
*
|
|
|
|
* Gets the singleton global object that represents the desktop.
|
|
|
|
*
|
|
|
|
* Return value: (transfer none): the singleton global object
|
|
|
|
*/
|
2008-10-31 00:22:44 -04:00
|
|
|
ShellGlobal *
|
|
|
|
shell_global_get (void)
|
|
|
|
{
|
|
|
|
static ShellGlobal *the_object = NULL;
|
|
|
|
|
|
|
|
if (!the_object)
|
|
|
|
the_object = g_object_new (SHELL_TYPE_GLOBAL, 0);
|
|
|
|
|
|
|
|
return the_object;
|
|
|
|
}
|
|
|
|
|
2008-10-31 14:24:29 -04:00
|
|
|
/**
|
|
|
|
* shell_global_set_stage_input_area:
|
|
|
|
* x: X coordinate of rectangle
|
|
|
|
* y: X coordinate of rectangle
|
|
|
|
* width: width of rectangle
|
|
|
|
* height: Height of rectangle
|
|
|
|
*
|
|
|
|
* Sets the area of the stage that is responsive to mouse clicks as
|
|
|
|
* a rectangle.
|
|
|
|
*/
|
2008-10-31 00:22:44 -04:00
|
|
|
void
|
2008-10-31 11:20:54 -04:00
|
|
|
shell_global_set_stage_input_area (ShellGlobal *global,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int width,
|
|
|
|
int height)
|
2008-10-31 00:22:44 -04:00
|
|
|
{
|
2008-10-31 11:20:54 -04:00
|
|
|
g_return_if_fail (SHELL_IS_GLOBAL (global));
|
2008-10-31 00:22:44 -04:00
|
|
|
|
2008-10-31 11:20:54 -04:00
|
|
|
mutter_plugin_set_stage_input_area (global->plugin, x, y, width, height);
|
2008-10-31 00:22:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-10-31 11:20:54 -04:00
|
|
|
_shell_global_set_plugin (ShellGlobal *global,
|
|
|
|
MutterPlugin *plugin)
|
2008-10-31 00:22:44 -04:00
|
|
|
{
|
2008-10-31 11:20:54 -04:00
|
|
|
g_return_if_fail (SHELL_IS_GLOBAL (global));
|
|
|
|
|
|
|
|
global->plugin = plugin;
|
2008-10-31 00:22:44 -04:00
|
|
|
}
|