1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
7 * Copyright (C) 2004 Novell, Inc.
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
39 text_received_cb (GtkClipboard
*clipboard
, const char *text
, gpointer data
)
44 if (text
!= NULL
&& strlen (text
) > 2) {
46 cpy
= g_strdup (text
);
48 /* Remove trailing gunk */
50 while (i
> 0 && cpy
[i
] == 10) {
55 /* Remove excess whitespace. */
58 /* Searchs for best in the PATH. */
59 execlp ("best", "best", "--no-tray", cpy
, NULL
);
67 request_text (gpointer data
)
70 GtkClipboard
*clipboard
;
72 my_widget
= GTK_WIDGET (data
);
73 clipboard
= gtk_widget_get_clipboard (my_widget
, GDK_SELECTION_PRIMARY
);
74 gtk_clipboard_request_text (clipboard
, text_received_cb
, my_widget
);
80 main (int argc
, char *argv
[])
84 gtk_init (&argc
, &argv
);
86 /* We need a widget, so we create (but don't show) a window. */
87 window
= gtk_window_new (GTK_WINDOW_TOPLEVEL
);
89 g_idle_add (request_text
, window
);