~ubuntu-core-dev/update-notifier/ubuntu

« back to all changes in this revision

Viewing changes to src/clipboard.c

  • Committer: Julian Andres Klode
  • Date: 2020-01-28 09:54:52 UTC
  • Revision ID: juliank@ubuntu.com-20200128095452-g0q3a1xg75a7k56j
Replace pep8 with pycodestyle

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 <gconf/gconf-client.h>
14
 
#include <gdk/gdkx.h>
15
 
 
16
 
#include "update-notifier.h"
17
 
 
18
 
/*
19
 
 * clipboard_get_func - dummy get_func for gtk_clipboard_set_with_data ()
20
 
 */
21
 
static void
22
 
clipboard_get_func (GtkClipboard *clipboard __attribute__((__unused__)),
23
 
                   GtkSelectionData *selection_data __attribute__((__unused__)),
24
 
                    guint info __attribute__((__unused__)),
25
 
                    gpointer user_data_or_owner __attribute__((__unused__)))
26
 
{
27
 
}
28
 
 
29
 
/*
30
 
 * clipboard_clear_func - dummy clear_func for gtk_clipboard_set_with_data ()
31
 
 */
32
 
static void
33
 
clipboard_clear_func (GtkClipboard *clipboard __attribute__((__unused__)),
34
 
                      gpointer user_data_or_owner __attribute__((__unused__)))
35
 
{
36
 
}
37
 
 
38
 
/*
39
 
 * up_get_clipboard - try and get the CLIPBOARD_NAME clipboard
40
 
 *
41
 
 * Returns TRUE if successfully retrieved and FALSE otherwise.
42
 
 */
43
 
gboolean
44
 
up_get_clipboard (void)
45
 
{
46
 
        static const GtkTargetEntry targets[] = { {CLIPBOARD_NAME, 0, 0} };
47
 
        gboolean retval = FALSE;
48
 
        GtkClipboard *clipboard;
49
 
        Atom atom;
50
 
 
51
 
        atom = gdk_x11_get_xatom_by_name (CLIPBOARD_NAME);
52
 
 
53
 
        XGrabServer (GDK_DISPLAY ());
54
 
 
55
 
        if (XGetSelectionOwner (GDK_DISPLAY (), atom) != None)
56
 
                goto out;
57
 
 
58
 
        clipboard = gtk_clipboard_get (gdk_atom_intern (CLIPBOARD_NAME, FALSE));
59
 
 
60
 
        if (gtk_clipboard_set_with_data (clipboard, targets,
61
 
                                         G_N_ELEMENTS (targets),
62
 
                                         clipboard_get_func,
63
 
                                         clipboard_clear_func, NULL))
64
 
                retval = TRUE;
65
 
 
66
 
out:
67
 
        XUngrabServer (GDK_DISPLAY ());
68
 
        gdk_flush ();
69
 
 
70
 
        return retval;
71
 
}