View | Details | Raw Unified | Return to bug 114226
Collapse All | Expand All

(-)src/Makefile.am (+2 lines)
Lines 19-24 Link Here
19
resapplet_SOURCES =	\
19
resapplet_SOURCES =	\
20
	eggtrayicon.c	\
20
	eggtrayicon.c	\
21
	eggtrayicon.h	\
21
	eggtrayicon.h	\
22
	clipboard.c	\
23
	clipboard.h	\
22
	resapplet.c
24
	resapplet.c
23
25
24
resapplet_LDADD = @RESAPPLET_LIBS@
26
resapplet_LDADD = @RESAPPLET_LIBS@
(-)src/clipboard.c (+72 lines)
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
}
(-)src/clipboard.h (+8 lines)
Added Link Here
1
#ifndef __RESAPPLET_H__
2
#define __RESAPPLET_H__
3
4
#define CLIPBOARD_NAME		"RESAPPLET_SELECTION"
5
6
gboolean resapplet_get_clipboard (void);
7
8
#endif	/* __RESAPPLET_H__ */
(-)src/resapplet.c (-2 / +10 lines)
Lines 22-27 Link Here
22
#include <gconf/gconf-client.h>
22
#include <gconf/gconf-client.h>
23
#include <gtk/gtk.h>
23
#include <gtk/gtk.h>
24
24
25
#include "clipboard.h"
25
#include "eggtrayicon.h"
26
#include "eggtrayicon.h"
26
27
27
#include "config.h"
28
#include "config.h"
Lines 100-106 Link Here
100
{
101
{
101
	ScreenInfo *current_screen;
102
	ScreenInfo *current_screen;
102
	GdkWindow *root;
103
	GdkWindow *root;
103
	const char *tip;
104
	char *tip;
104
	gint gdk_depth;
105
	gint gdk_depth;
105
	guint depth;
106
	guint depth;
106
	
107
	
Lines 904-910 Link Here
904
905
905
	client = gnome_master_client ();
906
	client = gnome_master_client ();
906
	gnome_client_set_restart_command (client, argc, argv);
907
	gnome_client_set_restart_command (client, argc, argv);
907
	gnome_client_set_restart_style (client, GNOME_RESTART_IF_RUNNING);
908
	if (resapplet_get_clipboard ())
909
		gnome_client_set_restart_style (client,
910
						GNOME_RESTART_IF_RUNNING);
911
	else {
912
		/* if we are already running, silently exit */
913
		gnome_client_set_restart_style (client, GNOME_RESTART_NEVER);
914
		return 1;
915
	}
908
916
909
	gtk_init (&argc, &argv);
917
	gtk_init (&argc, &argv);
910
918

Return to bug 114226