|
Added
Link Here
|
| 1 |
/* |
| 2 |
* src/clipboard.c - X clipboard hack to detect if daemon is running |
| 3 |
* |
| 4 |
* Elliot Lee <sopwith@redhat.com> |
| 5 |
* |
| 6 |
* (C) Copyright 1999 Red Hat, Inc. |
| 7 |
* |
| 8 |
* Licensed under the GNU GPL v2. See COPYING. |
| 9 |
*/ |
| 10 |
|
| 11 |
#include "config.h" |
| 12 |
|
| 13 |
#include <gnome.h> |
| 14 |
#include <gconf/gconf-client.h> |
| 15 |
#include <gdk/gdkx.h> |
| 16 |
|
| 17 |
#include "clipboard.h" |
| 18 |
|
| 19 |
/* |
| 20 |
* clipboard_get_func - dummy get_func for gtk_clipboard_set_with_data () |
| 21 |
*/ |
| 22 |
static void |
| 23 |
clipboard_get_func (GtkClipboard *clipboard G_GNUC_UNUSED, |
| 24 |
GtkSelectionData *selection_data G_GNUC_UNUSED, |
| 25 |
guint info G_GNUC_UNUSED, |
| 26 |
gpointer user_data_or_owner G_GNUC_UNUSED) |
| 27 |
{ |
| 28 |
} |
| 29 |
|
| 30 |
/* |
| 31 |
* clipboard_clear_func - dummy clear_func for gtk_clipboard_set_with_data () |
| 32 |
*/ |
| 33 |
static void |
| 34 |
clipboard_clear_func (GtkClipboard *clipboard G_GNUC_UNUSED, |
| 35 |
gpointer user_data_or_owner G_GNUC_UNUSED) |
| 36 |
{ |
| 37 |
} |
| 38 |
|
| 39 |
/* |
| 40 |
* resapplet_get_clipboard - try and get the CLIPBOARD_NAME clipboard |
| 41 |
* |
| 42 |
* Returns TRUE if successfully retrieved and FALSE otherwise. |
| 43 |
*/ |
| 44 |
gboolean |
| 45 |
resapplet_get_clipboard (void) |
| 46 |
{ |
| 47 |
static const GtkTargetEntry targets[] = { {CLIPBOARD_NAME, 0, 0} }; |
| 48 |
gboolean retval = FALSE; |
| 49 |
GtkClipboard *clipboard; |
| 50 |
Atom atom; |
| 51 |
|
| 52 |
atom = gdk_x11_get_xatom_by_name (CLIPBOARD_NAME); |
| 53 |
|
| 54 |
XGrabServer (GDK_DISPLAY ()); |
| 55 |
|
| 56 |
if (XGetSelectionOwner (GDK_DISPLAY (), atom) != None) |
| 57 |
goto out; |
| 58 |
|
| 59 |
clipboard = gtk_clipboard_get (gdk_atom_intern (CLIPBOARD_NAME, FALSE)); |
| 60 |
|
| 61 |
if (gtk_clipboard_set_with_data (clipboard, targets, |
| 62 |
G_N_ELEMENTS (targets), |
| 63 |
clipboard_get_func, |
| 64 |
clipboard_clear_func, NULL)) |
| 65 |
retval = TRUE; |
| 66 |
|
| 67 |
out: |
| 68 |
XUngrabServer (GDK_DISPLAY ()); |
| 69 |
gdk_flush (); |
| 70 |
|
| 71 |
return retval; |
| 72 |
} |