2 * Copyright (C) 2011 Red Hat, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
22 GtkClipboard *clipboard;
29 image_request_cb (GtkClipboard *clipboard,
41 height = gdk_pixbuf_get_height (pixbuf);
42 width = gdk_pixbuf_get_width (pixbuf);
44 factor = MAX ((SIZE / height), (SIZE / width));
46 copy = gdk_pixbuf_scale_simple (pixbuf, width * factor, height * factor, GDK_INTERP_BILINEAR);
47 gtk_image_set_from_pixbuf (GTK_IMAGE (image), copy);
48 g_object_unref (copy);
49 str = g_strdup_printf ("<b>Image</b> %d \342\234\225 %d", width, height);
53 str = g_strdup ("<b>No image data</b>");
55 gtk_label_set_markup (GTK_LABEL (label), str);
62 gtk_clipboard_request_image (clipboard, image_request_cb, NULL);
66 on_owner_change (GtkClipboard *clipboard,
74 on_response (GtkDialog *dialog,
85 theme = gtk_icon_theme_get_default ();
86 pixbuf = gtk_icon_theme_load_icon (theme, "terminal", 1600, 0, NULL);
87 gtk_clipboard_set_image (clipboard, pixbuf);
95 theme = gtk_icon_theme_get_default ();
96 pixbuf = gtk_icon_theme_load_icon (theme, "terminal", 48, 0, NULL);
97 gtk_clipboard_set_image (clipboard, pixbuf);
100 case GTK_RESPONSE_CLOSE:
108 main (int argc, char **argv)
112 gtk_init (&argc, &argv);
114 window = gtk_dialog_new_with_buttons ("Clipboard",
119 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
122 image = gtk_image_new ();
123 gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (window))), image, FALSE, FALSE, 0);
124 label = gtk_label_new ("No data found");
125 gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (window))), label, FALSE, FALSE, 0);
127 g_signal_connect (window, "response", G_CALLBACK (on_response), NULL);
129 clipboard = gtk_clipboard_get_for_display (gtk_widget_get_display (window),
130 GDK_SELECTION_CLIPBOARD);
131 g_signal_connect (clipboard, "owner-change", G_CALLBACK (on_owner_change), NULL);
135 gtk_widget_show_all (window);