mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-09-16 06:40:41 +00:00
2006-04-20 Robert Love <rml@novell.com>
* gnome/vpn-properties/nm-vpn-properties.c: Satisfy TODO: Ensure that only one copy of nm-vpn-properties is running at a time via the 'ol X selection trick. This prevents the user from opening two "VPN Connections" windows from within the applet, which leads to mass hysteria. * clipboard.c: New file, implementing simple X selection logic. * clipboard.h: New file. * gnome/vpn-properties/Makefile.am: Add clipboard.{c,h} git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1695 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
811c77c689
commit
eae1b63a1c
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2006-04-20 Robert Love <rml@novell.com>
|
||||
|
||||
* gnome/vpn-properties/nm-vpn-properties.c: Satisfy TODO: Ensure that
|
||||
only one copy of nm-vpn-properties is running at a time via the 'ol
|
||||
X selection trick. This prevents the user from opening two "VPN
|
||||
Connections" windows from within the applet, which leads to mass
|
||||
hysteria.
|
||||
* clipboard.c: New file, implementing simple X selection logic.
|
||||
* clipboard.h: New file.
|
||||
* gnome/vpn-properties/Makefile.am: Add clipboard.{c,h}
|
||||
|
||||
2006-04-18 Nicolas Trangez <eikke@eikke.com>
|
||||
|
||||
* backends/NetworkManagerGentoo.c: Small cleanups and enhancements
|
||||
|
|
|
@ -7,8 +7,10 @@ nm_vpn_properties_HEADERS = \
|
|||
nm-vpn-ui-interface.h
|
||||
|
||||
nm_vpn_properties_SOURCES = \
|
||||
nm-vpn-properties.c \
|
||||
nm-vpn-ui-interface.h
|
||||
nm-vpn-properties.c \
|
||||
clipboard.c \
|
||||
clipboard.h \
|
||||
nm-vpn-ui-interface.h
|
||||
|
||||
gladedir = $(datadir)/gnome-vpn-properties
|
||||
glade_DATA = nm-vpn-properties.glade
|
||||
|
|
74
gnome/vpn-properties/clipboard.c
Normal file
74
gnome/vpn-properties/clipboard.c
Normal file
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* src/clipboard.c - X clipboard hack to detect if daemon is running
|
||||
*
|
||||
* Elliot Lee <sopwith@redhat.com>
|
||||
*
|
||||
* (C) Copyright 1999 Red Hat, Inc.
|
||||
*
|
||||
* Licensed under the GNU GPL v2. See COPYING.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gnome.h>
|
||||
#include <gconf/gconf-client.h>
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
#include "clipboard.h"
|
||||
|
||||
/*
|
||||
* clipboard_get_func - dummy get_func for gtk_clipboard_set_with_data ()
|
||||
*/
|
||||
static void
|
||||
clipboard_get_func (GtkClipboard *clipboard __attribute__((__unused__)),
|
||||
GtkSelectionData *selection_data __attribute__((__unused__)),
|
||||
guint info __attribute__((__unused__)),
|
||||
gpointer user_data_or_owner __attribute__((__unused__)))
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* clipboard_clear_func - dummy clear_func for gtk_clipboard_set_with_data ()
|
||||
*/
|
||||
static void
|
||||
clipboard_clear_func (GtkClipboard *clipboard __attribute__((__unused__)),
|
||||
gpointer user_data_or_owner __attribute__((__unused__)))
|
||||
{
|
||||
}
|
||||
|
||||
#define CLIPBOARD_NAME "VPN_CLIPBOARD_FOO"
|
||||
|
||||
/*
|
||||
* vpn_get_clipboard - try and get the CLIPBOARD_NAME clipboard
|
||||
*
|
||||
* Returns TRUE if successfully retrieved and FALSE otherwise.
|
||||
*/
|
||||
gboolean
|
||||
vpn_get_clipboard (void)
|
||||
{
|
||||
static const GtkTargetEntry targets[] = { {CLIPBOARD_NAME, 0, 0} };
|
||||
gboolean retval = FALSE;
|
||||
GtkClipboard *clipboard;
|
||||
Atom atom;
|
||||
|
||||
atom = gdk_x11_get_xatom_by_name (CLIPBOARD_NAME);
|
||||
|
||||
XGrabServer (GDK_DISPLAY ());
|
||||
|
||||
if (XGetSelectionOwner (GDK_DISPLAY (), atom) != None)
|
||||
goto out;
|
||||
|
||||
clipboard = gtk_clipboard_get (gdk_atom_intern (CLIPBOARD_NAME, FALSE));
|
||||
|
||||
if (gtk_clipboard_set_with_data (clipboard, targets,
|
||||
G_N_ELEMENTS (targets),
|
||||
clipboard_get_func,
|
||||
clipboard_clear_func, NULL))
|
||||
retval = TRUE;
|
||||
|
||||
out:
|
||||
XUngrabServer (GDK_DISPLAY ());
|
||||
gdk_flush ();
|
||||
|
||||
return retval;
|
||||
}
|
6
gnome/vpn-properties/clipboard.h
Normal file
6
gnome/vpn-properties/clipboard.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef _VPN_PROPERTIES_CLIPBOARD_H
|
||||
#define _VPN_PROPERTIES_CLIPBOARD_H
|
||||
|
||||
gboolean vpn_get_clipboard (void);
|
||||
|
||||
#endif /* _VPN_PROPERTIES_CLIPBOARD_H */
|
|
@ -43,6 +43,7 @@
|
|||
|
||||
#define NM_VPN_API_SUBJECT_TO_CHANGE
|
||||
#include "nm-vpn-ui-interface.h"
|
||||
#include "clipboard.h"
|
||||
|
||||
#define NM_GCONF_VPN_CONNECTIONS_PATH "/system/networking/vpn_connections"
|
||||
|
||||
|
@ -926,7 +927,8 @@ init_app (void)
|
|||
GtkWidget *toplevel;
|
||||
GDir *dir;
|
||||
|
||||
/* TODO: ensure only one copy of this program is running at any time */
|
||||
if (!vpn_get_clipboard ())
|
||||
return FALSE;
|
||||
|
||||
gconf_client = gconf_client_get_default ();
|
||||
gconf_client_add_dir (gconf_client, NM_GCONF_VPN_CONNECTIONS_PATH,
|
||||
|
|
Loading…
Reference in a new issue