diff options
author | Ulf Lamping <ulf.lamping@web.de> | 2004-07-22 18:42:50 +0000 |
---|---|---|
committer | Ulf Lamping <ulf.lamping@web.de> | 2004-07-22 18:42:50 +0000 |
commit | f6c9daa5ecdc2e375adbb3a39bac49a49e7ebfb6 (patch) | |
tree | b2d30bb2792b7dd49f263463b9115a8e9df2c89d /gtk/hostlist_table.c | |
parent | cf51c277bb6bfe16f0b2167412a3a4ac0b7208b6 (diff) |
use gtk_clipboard_get(), so the "copy to clipboard" is available in all GTK2 versions
svn path=/trunk/; revision=11472
Diffstat (limited to 'gtk/hostlist_table.c')
-rw-r--r-- | gtk/hostlist_table.c | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/gtk/hostlist_table.c b/gtk/hostlist_table.c index 388a580c42..c06ad3e813 100644 --- a/gtk/hostlist_table.c +++ b/gtk/hostlist_table.c @@ -543,15 +543,13 @@ draw_hostlist_table_data(hostlist_table *hl) gtk_clist_thaw(hl->table); } -/* GdkDisplay is only available in GTK 2.2 and later */ -#if (GTK_MAJOR_VERSION > 2) || ( (GTK_MAJOR_VERSION == 2) && (GTK_MINOR_VERSION >= 2) ) +#if (GTK_MAJOR_VERSION > 2) static void copy_as_csv_cb(GtkWindow *win _U_, gpointer data) { guint32 i,j; gchar *table_entry; GtkClipboard *cb; - GdkDisplay *disp; GString *CSV_str = g_string_new(""); hostlist_table *hosts=(hostlist_table *)data; @@ -578,10 +576,9 @@ copy_as_csv_cb(GtkWindow *win _U_, gpointer data) } /* Now that we have the CSV data, copy it into the default clipboard */ - disp = gdk_display_get_default(); - cb = gtk_clipboard_get_for_display (disp,GDK_SELECTION_CLIPBOARD); /* Get the default clipboard */ - gtk_clipboard_set_text(cb, CSV_str->str, -1); /* Copy the CSV data into the clipboard */ - g_string_free(CSV_str, TRUE); /* Free the memory */ + cb = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); /* Get the default clipboard */ + gtk_clipboard_set_text(cb, CSV_str->str, -1); /* Copy the CSV data into the clipboard */ + g_string_free(CSV_str, TRUE); /* Free the memory */ } #endif @@ -595,7 +592,7 @@ init_hostlist_table_page(hostlist_table *hosttable, GtkWidget *vbox, gboolean hi GtkWidget *column_lb; GString *error_string; char title[256]; -#if (GTK_MAJOR_VERSION > 2) || ( (GTK_MAJOR_VERSION == 2) && (GTK_MINOR_VERSION >= 2) ) +#if (GTK_MAJOR_VERSION > 2) GtkWidget *copy_bt; GtkTooltips *tooltips = gtk_tooltips_new(); #endif @@ -658,19 +655,6 @@ init_hostlist_table_page(hostlist_table *hosttable, GtkWidget *vbox, gboolean hi gtk_clist_set_column_auto_resize(hosttable->table, 6, TRUE); gtk_clist_set_column_auto_resize(hosttable->table, 7, TRUE); -#if 0 - /*XXX instead of this we should probably have some code to - dynamically adjust the width of the columns */ - gtk_clist_set_column_width(hosttable->table, 0, 100); - gtk_clist_set_column_width(hosttable->table, 1, 40); - gtk_clist_set_column_width(hosttable->table, 2, 70); - gtk_clist_set_column_width(hosttable->table, 3, 60); - gtk_clist_set_column_width(hosttable->table, 4, 70); - gtk_clist_set_column_width(hosttable->table, 5, 60); - gtk_clist_set_column_width(hosttable->table, 6, 70); - gtk_clist_set_column_width(hosttable->table, 7, 60); -#endif - gtk_clist_set_shadow_type(hosttable->table, GTK_SHADOW_IN); gtk_clist_column_titles_show(hosttable->table); gtk_container_add(GTK_CONTAINER(hosttable->scrolled_window), (GtkWidget *)hosttable->table); @@ -688,9 +672,12 @@ init_hostlist_table_page(hostlist_table *hosttable, GtkWidget *vbox, gboolean hi /* create popup menu for this table */ hostlist_create_popup_menu(hosttable); -#if (GTK_MAJOR_VERSION > 2) || ( (GTK_MAJOR_VERSION == 2) && (GTK_MINOR_VERSION >= 2) ) - copy_bt = gtk_button_new_with_label ("Copy content to clipboard as CSV"); - gtk_tooltips_set_tip(tooltips, copy_bt, "Copy all statistical values to the clipboard in CSV (Comma Seperated Values) format.", NULL); +#if (GTK_MAJOR_VERSION > 2) + /* XXX - maybe we want to have a "Copy as CSV" stock button here? */ + /*copy_bt = gtk_button_new_with_label ("Copy content to clipboard as CSV");*/ + copy_bt = BUTTON_NEW_FROM_STOCK(GTK_STOCK_COPY); + gtk_tooltips_set_tip(tooltips, copy_bt, + "Copy all statistical values of this page to the clipboard in CSV (Comma Seperated Values) format.", NULL); SIGNAL_CONNECT(copy_bt, "clicked", copy_as_csv_cb,(gpointer *) hosttable); gtk_box_pack_start(GTK_BOX(vbox), copy_bt, FALSE, FALSE, 0); #endif |