~ubuntu-branches/debian/sid/xfce4-clipman-plugin/sid

« back to all changes in this revision

Viewing changes to panel-plugin/xfce4-popup-clipman.c

  • Committer: Bazaar Package Importer
  • Author(s): Yves-Alexis Perez
  • Date: 2009-04-21 07:48:11 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090421074811-ro4ri3jy2lhbhcij
Tags: 2:1.0.0-1
* New upstream release.
  + ship a shortcutable binary to popup plugin.               closes: #405556
* debian/control:
  - move package to xfce section.
  - bump build-deps for Xfce 4.6.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Clipman - panel plugin for Xfce Desktop Environment
 
3
 *            popup command to show the clipman menu
 
4
 *  Copyright (C) 2002-2006  Olivier Fourdan
 
5
 *                2008-2009  Mike Massonnet <mmassonnet@xfce.org>
 
6
 *
 
7
 *  This program is free software; you can redistribute it and/or modify
 
8
 *  it under the terms of the GNU General Public License as published by
 
9
 *  the Free Software Foundation; either version 2 of the License, or
 
10
 *  (at your option) any later version.
 
11
 *
 
12
 *  This program is distributed in the hope that it will be useful,
 
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 *  GNU General Public License for more details.
 
16
 *
 
17
 *  You should have received a copy of the GNU General Public License
 
18
 *  along with this program; if not, write to the Free Software
 
19
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
20
 */
 
21
 
 
22
#ifdef HAVE_CONFIG_H
 
23
#include <config.h>
 
24
#endif
 
25
 
 
26
#include <X11/Xlib.h>
 
27
#include <gdk/gdkx.h>
 
28
#include <gtk/gtk.h>
 
29
 
 
30
#include "common.h"
 
31
 
 
32
static gboolean
 
33
clipman_plugin_check_is_running (GtkWidget *widget,
 
34
                                 Window *xid)
 
35
{
 
36
  GdkScreen          *gscreen;
 
37
  gchar              *selection_name;
 
38
  Atom                selection_atom;
 
39
 
 
40
  gscreen = gtk_widget_get_screen (widget);
 
41
  selection_name = g_strdup_printf (XFCE_CLIPMAN_SELECTION"%d",
 
42
                                    gdk_screen_get_number (gscreen));
 
43
  selection_atom = XInternAtom (GDK_DISPLAY(), selection_name, FALSE);
 
44
 
 
45
  if ((*xid = XGetSelectionOwner (GDK_DISPLAY(), selection_atom)))
 
46
    return TRUE;
 
47
 
 
48
  return FALSE;
 
49
}
 
50
 
 
51
gint
 
52
main (gint argc, gchar *argv[])
 
53
{
 
54
  GdkEventClient        gev;
 
55
  GtkWidget            *win;
 
56
  Window                id;
 
57
 
 
58
  gtk_init (&argc, &argv);
 
59
 
 
60
  win = gtk_invisible_new ();
 
61
  gtk_widget_realize (win);
 
62
 
 
63
  gev.type              = GDK_CLIENT_EVENT;
 
64
  gev.window            = win->window;
 
65
  gev.send_event        = TRUE;
 
66
  gev.message_type      = gdk_atom_intern ("STRING", FALSE);
 
67
  gev.data_format       = 8;
 
68
  g_snprintf (gev.data.b, sizeof (gev.data.b), XFCE_CLIPMAN_MESSAGE);
 
69
 
 
70
  if (clipman_plugin_check_is_running (win, &id))
 
71
    gdk_event_send_client_message ((GdkEvent *)&gev, (GdkNativeWindow)id);
 
72
  else
 
73
    g_warning ("Can't find the xfce4-clipman-plugin.\n");
 
74
  gdk_flush ();
 
75
 
 
76
  gtk_widget_destroy (win);
 
77
 
 
78
  return FALSE;
 
79
}
 
80