[PATCH 3/3] glib: add copy button to selections demo
Adrian Johnson
ajohnson at redneon.com
Tue Feb 28 03:08:19 PST 2012
---
glib/demo/selections.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/glib/demo/selections.c b/glib/demo/selections.c
index 881733e..3912dc6 100644
--- a/glib/demo/selections.c
+++ b/glib/demo/selections.c
@@ -34,6 +34,7 @@ typedef struct {
GtkWidget *darea;
GtkWidget *fg_color_button;
GtkWidget *bg_color_button;
+ GtkWidget *copy_button;
PopplerPage *page;
cairo_surface_t *surface;
@@ -76,6 +77,7 @@ pgd_selections_clear_selections (PgdSelectionsDemo *demo)
cairo_region_destroy (demo->selected_region);
demo->selected_region = NULL;
}
+ gtk_widget_set_sensitive(demo->copy_button, FALSE);
}
static void
@@ -146,6 +148,7 @@ pgd_selections_update_seleted_text (PgdSelectionsDemo *demo)
if (text) {
demo->selected_text = g_utf8_normalize (text, -1, G_NORMALIZE_NFKC);
g_free (text);
+ gtk_widget_set_sensitive(demo->copy_button, TRUE);
}
}
@@ -430,6 +433,15 @@ pgd_selections_render (GtkButton *button,
}
static void
+pgd_selections_copy (GtkButton *button,
+ PgdSelectionsDemo *demo)
+{
+ GtkClipboard *clipboard = gtk_clipboard_get_for_display(gdk_display_get_default(),
+ GDK_SELECTION_CLIPBOARD);
+ gtk_clipboard_set_text (clipboard, demo->selected_text, -1);
+}
+
+static void
pgd_selections_page_selector_value_changed (GtkSpinButton *spinbutton,
PgdSelectionsDemo *demo)
{
@@ -599,6 +611,14 @@ pgd_selections_properties_selector_create (PgdSelectionsDemo *demo)
gtk_box_pack_start (GTK_BOX (hbox), color_hbox, FALSE, TRUE, 0);
gtk_widget_show (color_hbox);
+ demo->copy_button = gtk_button_new_with_label ("Copy");
+ g_signal_connect (G_OBJECT (demo->copy_button), "clicked",
+ G_CALLBACK (pgd_selections_copy),
+ (gpointer)demo);
+ gtk_box_pack_end (GTK_BOX (hbox), demo->copy_button, FALSE, TRUE, 0);
+ gtk_widget_set_sensitive(demo->copy_button, FALSE);
+ gtk_widget_show (demo->copy_button);
+
button = gtk_button_new_with_label ("Render");
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (pgd_selections_render),
--
1.7.5.4
--------------040904090202000503090705--
More information about the poppler
mailing list