Make a GObject (#75970, James Henstridge)

Tue Sep 24 18:18:36 2002  Owen Taylor  <otaylor@redhat.com>
        * gtk/gtkclipboard.[ch]: Make a GObject (#75970, James
        Henstridge)
This commit is contained in:
Owen Taylor 2002-09-24 23:59:32 +00:00 committed by Owen Taylor
parent 6a7d4ee3ae
commit 273f99112e
8 changed files with 110 additions and 1 deletions

View File

@ -1,3 +1,8 @@
Tue Sep 24 18:18:36 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkclipboard.[ch]: Make a GObject (#75970, James
Henstridge)
Tue Sep 24 19:45:55 2002 Owen Taylor <otaylor@redhat.com> Tue Sep 24 19:45:55 2002 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkwindow-x11.c (gdk_window_impl_x11_get_colormap): * gdk/x11/gdkwindow-x11.c (gdk_window_impl_x11_get_colormap):

View File

@ -1,3 +1,8 @@
Tue Sep 24 18:18:36 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkclipboard.[ch]: Make a GObject (#75970, James
Henstridge)
Tue Sep 24 19:45:55 2002 Owen Taylor <otaylor@redhat.com> Tue Sep 24 19:45:55 2002 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkwindow-x11.c (gdk_window_impl_x11_get_colormap): * gdk/x11/gdkwindow-x11.c (gdk_window_impl_x11_get_colormap):

View File

@ -1,3 +1,8 @@
Tue Sep 24 18:18:36 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkclipboard.[ch]: Make a GObject (#75970, James
Henstridge)
Tue Sep 24 19:45:55 2002 Owen Taylor <otaylor@redhat.com> Tue Sep 24 19:45:55 2002 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkwindow-x11.c (gdk_window_impl_x11_get_colormap): * gdk/x11/gdkwindow-x11.c (gdk_window_impl_x11_get_colormap):

View File

@ -1,3 +1,8 @@
Tue Sep 24 18:18:36 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkclipboard.[ch]: Make a GObject (#75970, James
Henstridge)
Tue Sep 24 19:45:55 2002 Owen Taylor <otaylor@redhat.com> Tue Sep 24 19:45:55 2002 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkwindow-x11.c (gdk_window_impl_x11_get_colormap): * gdk/x11/gdkwindow-x11.c (gdk_window_impl_x11_get_colormap):

View File

@ -1,3 +1,8 @@
Tue Sep 24 18:18:36 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkclipboard.[ch]: Make a GObject (#75970, James
Henstridge)
Tue Sep 24 19:45:55 2002 Owen Taylor <otaylor@redhat.com> Tue Sep 24 19:45:55 2002 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkwindow-x11.c (gdk_window_impl_x11_get_colormap): * gdk/x11/gdkwindow-x11.c (gdk_window_impl_x11_get_colormap):

View File

@ -1,3 +1,8 @@
Tue Sep 24 18:18:36 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkclipboard.[ch]: Make a GObject (#75970, James
Henstridge)
Tue Sep 24 19:45:55 2002 Owen Taylor <otaylor@redhat.com> Tue Sep 24 19:45:55 2002 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkwindow-x11.c (gdk_window_impl_x11_get_colormap): * gdk/x11/gdkwindow-x11.c (gdk_window_impl_x11_get_colormap):

View File

@ -34,11 +34,15 @@
#include "win32/gdkwin32.h" #include "win32/gdkwin32.h"
#endif #endif
typedef struct _GtkClipboardClass GtkClipboardClass;
typedef struct _RequestContentsInfo RequestContentsInfo; typedef struct _RequestContentsInfo RequestContentsInfo;
typedef struct _RequestTextInfo RequestTextInfo; typedef struct _RequestTextInfo RequestTextInfo;
struct _GtkClipboard struct _GtkClipboard
{ {
GObjectClass parent_instance;
GdkAtom selection; GdkAtom selection;
GtkClipboardGetFunc get_func; GtkClipboardGetFunc get_func;
@ -52,6 +56,11 @@ struct _GtkClipboard
GdkDisplay *display; GdkDisplay *display;
}; };
struct _GtkClipboardClass
{
GObjectClass parent_class;
};
struct _RequestContentsInfo struct _RequestContentsInfo
{ {
GtkClipboardReceivedFunc callback; GtkClipboardReceivedFunc callback;
@ -64,6 +73,9 @@ struct _RequestTextInfo
gpointer user_data; gpointer user_data;
}; };
static void gtk_clipboard_class_init (GtkClipboardClass *class);
static void gtk_clipboard_finalize (GObject *object);
static void clipboard_unset (GtkClipboard *clipboard); static void clipboard_unset (GtkClipboard *clipboard);
static void selection_received (GtkWidget *widget, static void selection_received (GtkWidget *widget,
GtkSelectionData *selection_data, GtkSelectionData *selection_data,
@ -82,6 +94,65 @@ static GQuark request_contents_key_id = 0;
static const gchar *clipboards_owned_key = "gtk-clipboards-owned"; static const gchar *clipboards_owned_key = "gtk-clipboards-owned";
static GQuark clipboards_owned_key_id = 0; static GQuark clipboards_owned_key_id = 0;
GObjectClass *parent_class;
GType
gtk_clipboard_get_type (void)
{
static GType clipboard_type = 0;
if (!clipboard_type)
{
static const GTypeInfo clipboard_info =
{
sizeof (GtkClipboardClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gtk_clipboard_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GtkClipboard),
0, /* n_preallocs */
(GInstanceInitFunc) NULL,
};
clipboard_type = g_type_register_static (G_TYPE_OBJECT, "GtkClipboard", &clipboard_info, 0);
}
return clipboard_type;
}
static void
gtk_clipboard_class_init (GtkClipboardClass *class)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
parent_class = g_type_class_peek_parent (class);
gobject_class->finalize = gtk_clipboard_finalize;
}
static void
gtk_clipboard_finalize (GObject *object)
{
clipboard_unset (GTK_CLIPBOARD (object));
}
static void
clipboard_display_closed (GdkDisplay *display,
gboolean is_error,
GtkClipboard *clipboard)
{
GSList *clipboards;
clipboards = g_object_get_data (G_OBJECT (display), "gtk-clipboard-list");
g_object_run_dispose (G_OBJECT (clipboard));
g_object_unref (clipboard);
clipboards = g_slist_remove (clipboards, clipboard);
g_object_set_data (G_OBJECT (display), "gtk-clipboard-list", clipboards);
}
/** /**
* gtk_clipboard_get_for_display: * gtk_clipboard_get_for_display:
* @display: the display for which the clipboard is to be retrieved or created * @display: the display for which the clipboard is to be retrieved or created
@ -128,6 +199,7 @@ gtk_clipboard_get_for_display (GdkDisplay *display, GdkAtom selection)
GSList *tmp_list; GSList *tmp_list;
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL); g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
g_return_val_if_fail (!display->closed, NULL);
if (selection == GDK_NONE) if (selection == GDK_NONE)
selection = GDK_SELECTION_CLIPBOARD; selection = GDK_SELECTION_CLIPBOARD;
@ -146,11 +218,13 @@ gtk_clipboard_get_for_display (GdkDisplay *display, GdkAtom selection)
if (!tmp_list) if (!tmp_list)
{ {
clipboard = g_new0 (GtkClipboard, 1); clipboard = g_object_new (GTK_TYPE_CLIPBOARD, NULL);
clipboard->selection = selection; clipboard->selection = selection;
clipboard->display = display; clipboard->display = display;
clipboards = g_slist_prepend (clipboards, clipboard); clipboards = g_slist_prepend (clipboards, clipboard);
g_object_set_data (G_OBJECT (display), "gtk-clipboard-list", clipboards); g_object_set_data (G_OBJECT (display), "gtk-clipboard-list", clipboards);
g_signal_connect (display, "closed",
G_CALLBACK (clipboard_display_closed), clipboard);
} }
return clipboard; return clipboard;

View File

@ -28,6 +28,9 @@ extern "C" {
#include <gtk/gtkselection.h> #include <gtk/gtkselection.h>
#define GTK_TYPE_CLIPBOARD (gtk_clipboard_get_type ())
#define GTK_CLIPBOARD(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_CLIPBOARD, GtkClipboard))
#define GTK_IS_CLIPBOARD(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_CLIPBOARD))
typedef void (* GtkClipboardReceivedFunc) (GtkClipboard *clipboard, typedef void (* GtkClipboardReceivedFunc) (GtkClipboard *clipboard,
GtkSelectionData *selection_data, GtkSelectionData *selection_data,
@ -47,6 +50,8 @@ typedef void (* GtkClipboardGetFunc) (GtkClipboard *clipboard,
typedef void (* GtkClipboardClearFunc) (GtkClipboard *clipboard, typedef void (* GtkClipboardClearFunc) (GtkClipboard *clipboard,
gpointer user_data_or_owner); gpointer user_data_or_owner);
GType gtk_clipboard_get_type (void);
GtkClipboard *gtk_clipboard_get_for_display (GdkDisplay *display, GtkClipboard *gtk_clipboard_get_for_display (GdkDisplay *display,
GdkAtom selection); GdkAtom selection);
#ifndef GDK_MULTIHEAD_SAFE #ifndef GDK_MULTIHEAD_SAFE