display: Make opened signal have a vfunc

... instead of g_signal_connect()ing in every init function.
This commit is contained in:
Benjamin Otte 2013-04-17 22:53:42 +01:00
parent 1fa29835a7
commit c86ac95ebf
2 changed files with 27 additions and 27 deletions

View File

@ -87,6 +87,29 @@ gdk_display_real_make_default (GdkDisplay *display)
{
}
static void
device_removed_cb (GdkDeviceManager *device_manager,
GdkDevice *device,
GdkDisplay *display)
{
g_hash_table_remove (display->multiple_click_info, device);
g_hash_table_remove (display->device_grabs, device);
g_hash_table_remove (display->pointers_info, device);
/* FIXME: change core pointer and remove from device list */
}
static void
gdk_display_real_opened (GdkDisplay *display)
{
GdkDeviceManager *device_manager;
device_manager = gdk_display_get_device_manager (display);
g_signal_connect (device_manager, "device-removed",
G_CALLBACK (device_removed_cb), display);
}
static void
gdk_display_class_init (GdkDisplayClass *class)
{
@ -98,6 +121,7 @@ gdk_display_class_init (GdkDisplayClass *class)
class->get_app_launch_context = gdk_display_real_get_app_launch_context;
class->window_type = GDK_TYPE_WINDOW;
class->opened = gdk_display_real_opened;
class->make_default = gdk_display_real_make_default;
/**
@ -111,7 +135,8 @@ gdk_display_class_init (GdkDisplayClass *class)
g_signal_new (g_intern_static_string ("opened"),
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
G_STRUCT_OFFSET (GdkDisplayClass, opened),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
@ -165,29 +190,6 @@ free_device_grabs_foreach (gpointer key,
return TRUE;
}
static void
device_removed_cb (GdkDeviceManager *device_manager,
GdkDevice *device,
GdkDisplay *display)
{
g_hash_table_remove (display->multiple_click_info, device);
g_hash_table_remove (display->device_grabs, device);
g_hash_table_remove (display->pointers_info, device);
/* FIXME: change core pointer and remove from device list */
}
static void
gdk_display_opened (GdkDisplay *display)
{
GdkDeviceManager *device_manager;
device_manager = gdk_display_get_device_manager (display);
g_signal_connect (device_manager, "device-removed",
G_CALLBACK (device_removed_cb), display);
}
static void
gdk_display_init (GdkDisplay *display)
{
@ -205,9 +207,6 @@ gdk_display_init (GdkDisplay *display)
display->multiple_click_info = g_hash_table_new_full (NULL, NULL, NULL,
(GDestroyNotify) g_free);
g_signal_connect (display, "opened",
G_CALLBACK (gdk_display_opened), NULL);
_gdk_display_manager_add_display (gdk_display_manager_get (), display);
}

View File

@ -237,6 +237,7 @@ struct _GdkDisplayClass
const gchar *text);
/* Signals */
void (*opened) (GdkDisplay *display);
void (*closed) (GdkDisplay *display,
gboolean is_error);
};