MonitorManager: inherit directly from DisplayConfig instead of handling signals

This way we can handle properties too.
This commit is contained in:
Giovanni Campagna 2013-07-23 19:32:17 +02:00
parent ee6b729196
commit e2f06dfa8c

View File

@ -54,7 +54,7 @@ typedef enum {
struct _MetaMonitorManager struct _MetaMonitorManager
{ {
GObject parent_instance; MetaDBusDisplayConfigSkeleton parent_instance;
MetaMonitorBackend backend; MetaMonitorBackend backend;
@ -98,12 +98,11 @@ struct _MetaMonitorManager
#endif #endif
int dbus_name_id; int dbus_name_id;
MetaDBusDisplayConfig *skeleton;
}; };
struct _MetaMonitorManagerClass struct _MetaMonitorManagerClass
{ {
GObjectClass parent_class; MetaDBusDisplayConfigSkeletonClass parent_class;
}; };
enum { enum {
@ -113,7 +112,10 @@ enum {
static int signals[SIGNALS_LAST]; static int signals[SIGNALS_LAST];
G_DEFINE_TYPE (MetaMonitorManager, meta_monitor_manager, G_TYPE_OBJECT); static void meta_monitor_manager_display_config_init (MetaDBusDisplayConfigIface *iface);
G_DEFINE_TYPE_WITH_CODE (MetaMonitorManager, meta_monitor_manager, META_DBUS_TYPE_DISPLAY_CONFIG_SKELETON,
G_IMPLEMENT_INTERFACE (META_DBUS_TYPE_DISPLAY_CONFIG, meta_monitor_manager_display_config_init));
static void invalidate_logical_config (MetaMonitorManager *manager); static void invalidate_logical_config (MetaMonitorManager *manager);
@ -908,8 +910,6 @@ meta_monitor_manager_dispose (GObject *object)
manager->dbus_name_id = 0; manager->dbus_name_id = 0;
} }
g_clear_object (&manager->skeleton);
G_OBJECT_CLASS (meta_monitor_manager_parent_class)->dispose (object); G_OBJECT_CLASS (meta_monitor_manager_parent_class)->dispose (object);
} }
@ -975,10 +975,10 @@ make_display_name (MetaOutput *output)
} }
static gboolean static gboolean
handle_get_resources (MetaDBusDisplayConfig *skeleton, meta_monitor_manager_handle_get_resources (MetaDBusDisplayConfig *skeleton,
GDBusMethodInvocation *invocation, GDBusMethodInvocation *invocation)
MetaMonitorManager *manager)
{ {
MetaMonitorManager *manager = META_MONITOR_MANAGER (skeleton);
GVariantBuilder crtc_builder, output_builder, mode_builder; GVariantBuilder crtc_builder, output_builder, mode_builder;
unsigned int i, j; unsigned int i, j;
@ -1362,14 +1362,14 @@ apply_config_dummy (MetaMonitorManager *manager,
} }
static gboolean static gboolean
handle_apply_configuration (MetaDBusDisplayConfig *skeleton, meta_monitor_manager_handle_apply_configuration (MetaDBusDisplayConfig *skeleton,
GDBusMethodInvocation *invocation, GDBusMethodInvocation *invocation,
guint serial, guint serial,
gboolean persistent, gboolean persistent,
GVariant *crtcs, GVariant *crtcs,
GVariant *outputs, GVariant *outputs)
MetaMonitorManager *manager)
{ {
MetaMonitorManager *manager = META_MONITOR_MANAGER (skeleton);
GVariantIter crtc_iter, output_iter, *nested_outputs; GVariantIter crtc_iter, output_iter, *nested_outputs;
guint crtc_id; guint crtc_id;
int new_mode, x, y; int new_mode, x, y;
@ -1519,6 +1519,13 @@ handle_apply_configuration (MetaDBusDisplayConfig *skeleton,
return TRUE; return TRUE;
} }
static void
meta_monitor_manager_display_config_init (MetaDBusDisplayConfigIface *iface)
{
iface->handle_get_resources = meta_monitor_manager_handle_get_resources;
iface->handle_apply_configuration = meta_monitor_manager_handle_apply_configuration;
}
static void static void
on_bus_acquired (GDBusConnection *connection, on_bus_acquired (GDBusConnection *connection,
const char *name, const char *name,
@ -1526,14 +1533,7 @@ on_bus_acquired (GDBusConnection *connection,
{ {
MetaMonitorManager *manager = user_data; MetaMonitorManager *manager = user_data;
manager->skeleton = META_DBUS_DISPLAY_CONFIG (meta_dbus_display_config_skeleton_new ()); g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (manager),
g_signal_connect_object (manager->skeleton, "handle-get-resources",
G_CALLBACK (handle_get_resources), manager, 0);
g_signal_connect_object (manager->skeleton, "handle-apply-configuration",
G_CALLBACK (handle_apply_configuration), manager, 0);
g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (manager->skeleton),
connection, connection,
"/org/gnome/Mutter/DisplayConfig", "/org/gnome/Mutter/DisplayConfig",
NULL); NULL);