]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/clipbrd.cpp
Implemented user dashes for PS print.
[wxWidgets.git] / src / gtk1 / clipbrd.cpp
index 6f316b16ee3d326f1759a0ecd82886c405695629..8adca083d289f63850d253539cb5e025925dbbec 100644 (file)
@@ -7,10 +7,6 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "clipbrd.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
@@ -74,6 +70,7 @@ struct _GtkSelectionData
 // "selection_received" for targets
 //-----------------------------------------------------------------------------
 
+extern "C" {
 static void
 targets_selection_received( GtkWidget *WXUNUSED(widget),
                             GtkSelectionData *selection_data,
@@ -114,7 +111,7 @@ targets_selection_received( GtkWidget *WXUNUSED(widget),
                         wxT("selection received for targets, format %s"),
                         format.GetId().c_str() );
 
-//            printf( "format %s requested %s\n", 
+//            printf( "format %s requested %s\n",
 //                    gdk_atom_name( atoms[i] ),
 //                    gdk_atom_name( clipboard->m_targetRequested ) );
 
@@ -129,11 +126,13 @@ targets_selection_received( GtkWidget *WXUNUSED(widget),
 
     clipboard->m_waiting = FALSE;
 }
+}
 
 //-----------------------------------------------------------------------------
 // "selection_received" for the actual data
 //-----------------------------------------------------------------------------
 
+extern "C" {
 static void
 selection_received( GtkWidget *WXUNUSED(widget),
                     GtkSelectionData *selection_data,
@@ -169,24 +168,29 @@ selection_received( GtkWidget *WXUNUSED(widget),
         return;
     }
 
-    /* make sure we got the data in the correct form (selection type).
-       if so, copy data to target object */
+#if 0
+    This seems to cause problems somehow
+    // make sure we got the data in the correct form (selection type).
+    // if so, copy data to target object
     if (selection_data->type != GDK_SELECTION_TYPE_STRING)
     {
         clipboard->m_waiting = FALSE;
         return;
     }
+#endif
 
     data_object->SetData( format, (size_t) selection_data->length, (const char*) selection_data->data );
 
     wxTheClipboard->m_formatSupported = TRUE;
     clipboard->m_waiting = FALSE;
 }
+}
 
 //-----------------------------------------------------------------------------
 // "selection_clear"
 //-----------------------------------------------------------------------------
 
+extern "C" {
 static gint
 selection_clear_clip( GtkWidget *WXUNUSED(widget), GdkEventSelection *event )
 {
@@ -223,11 +227,13 @@ selection_clear_clip( GtkWidget *WXUNUSED(widget), GdkEventSelection *event )
     wxTheClipboard->m_waiting = FALSE;
     return TRUE;
 }
+}
 
 //-----------------------------------------------------------------------------
 // selection handler for supplying data
 //-----------------------------------------------------------------------------
 
+extern "C" {
 static void
 selection_handler( GtkWidget *WXUNUSED(widget),
                    GtkSelectionData *selection_data,
@@ -243,6 +249,16 @@ selection_handler( GtkWidget *WXUNUSED(widget),
 
     wxDataFormat format( selection_data->target );
 
+#ifdef __WXDEBUG__
+    wxLogTrace(TRACE_CLIPBOARD,
+               _T("clipboard data in format %s, GtkSelectionData is target=%s type=%s selection=%s"),
+               format.GetId().c_str(),
+               wxString::FromAscii(gdk_atom_name(selection_data->target)).c_str(),
+               wxString::FromAscii(gdk_atom_name(selection_data->type)).c_str(),
+               wxString::FromAscii(gdk_atom_name(selection_data->selection)).c_str()
+               );
+#endif
+
     if (!data->IsSupportedFormat( format )) return;
 
     int size = data->GetDataSize( format );
@@ -255,14 +271,15 @@ selection_handler( GtkWidget *WXUNUSED(widget),
     data->GetDataHere( selection_data->target, d );
 
     gtk_selection_data_set(
-        selection_data,
-        GDK_SELECTION_TYPE_STRING,
-        8*sizeof(gchar),
-        (unsigned char*) d,
-        size );
+            selection_data,
+            GDK_SELECTION_TYPE_STRING,
+            8 * sizeof(gchar),
+            (unsigned char*) d,
+            size-1 );
 
     free(d);
 }
+}
 
 //-----------------------------------------------------------------------------
 // wxClipboard
@@ -273,6 +290,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxClipboard,wxObject)
 wxClipboard::wxClipboard()
 {
     m_open = FALSE;
+    m_waiting = FALSE;
 
     m_ownsClipboard = FALSE;
     m_ownsPrimarySelection = FALSE;
@@ -413,9 +431,9 @@ bool wxClipboard::AddData( wxDataObject *data )
                     wxT("wxClipboard now supports atom %s"),
                     array[i].GetId().c_str() );
 
-//        printf( "added %s\n", 
+//        printf( "added %s\n",
 //                    gdk_atom_name( array[i].GetFormatId() ) );
-                    
+
         gtk_selection_add_target( GTK_WIDGET(m_clipboardWidget),
                                   clipboard,
                                   array[i],
@@ -470,11 +488,9 @@ bool wxClipboard::IsSupported( const wxDataFormat& format )
     /* store requested format to be asked for by callbacks */
     m_targetRequested = format;
 
-#if 0
     wxLogTrace( TRACE_CLIPBOARD,
                 wxT("wxClipboard:IsSupported: requested format: %s"),
                 format.GetId().c_str() );
-#endif
 
     wxCHECK_MSG( m_targetRequested, FALSE, wxT("invalid clipboard format") );
 
@@ -498,9 +514,7 @@ bool wxClipboard::IsSupported( const wxDataFormat& format )
 
     while (m_waiting) gtk_main_iteration();
 
-    if (!m_formatSupported) return FALSE;
-
-    return TRUE;
+    return m_formatSupported;
 }
 
 bool wxClipboard::GetData( wxDataObject& data )