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, see <http://www.gnu.org/licenses/>.
20 GtkClipboard *clipboard;
27 image_request_cb (GtkClipboard *clipboard,
39 height = gdk_pixbuf_get_height (pixbuf);
40 width = gdk_pixbuf_get_width (pixbuf);
42 factor = MAX ((SIZE / height), (SIZE / width));
44 copy = gdk_pixbuf_scale_simple (pixbuf, width * factor, height * factor, GDK_INTERP_BILINEAR);
45 gtk_image_set_from_pixbuf (GTK_IMAGE (image), copy);
46 g_object_unref (copy);
47 str = g_strdup_printf ("<b>Image</b> %d \342\234\225 %d", width, height);
51 str = g_strdup ("<b>No image data</b>");
53 gtk_label_set_markup (GTK_LABEL (label), str);
60 gtk_clipboard_request_image (clipboard, image_request_cb, NULL);
64 on_owner_change (GtkClipboard *clipboard,
72 on_response (GtkDialog *dialog,
83 theme = gtk_icon_theme_get_default ();
84 pixbuf = gtk_icon_theme_load_icon (theme, "terminal", 1600, 0, NULL);
85 gtk_clipboard_set_image (clipboard, pixbuf);
93 theme = gtk_icon_theme_get_default ();
94 pixbuf = gtk_icon_theme_load_icon (theme, "terminal", 48, 0, NULL);
95 gtk_clipboard_set_image (clipboard, pixbuf);
98 case GTK_RESPONSE_CLOSE:
106 main (int argc, char **argv)
110 gtk_init (&argc, &argv);
112 window = gtk_dialog_new_with_buttons ("Clipboard",
117 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
120 image = gtk_image_new ();
121 gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (window))), image, FALSE, FALSE, 0);
122 label = gtk_label_new ("No data found");
123 gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (window))), label, FALSE, FALSE, 0);
125 g_signal_connect (window, "response", G_CALLBACK (on_response), NULL);
127 clipboard = gtk_clipboard_get_for_display (gtk_widget_get_display (window),
128 GDK_SELECTION_CLIPBOARD);
129 g_signal_connect (clipboard, "owner-change", G_CALLBACK (on_owner_change), NULL);
133 gtk_widget_show_all (window);