static void chat_text_view_copy_clipboard (EmpathyChatView *view) { GtkTextBuffer *buffer; GtkTextIter start, iter, end; GtkClipboard *clipboard; GdkPixbuf *pixbuf; gunichar c; GtkTextChildAnchor *anchor = NULL; GString *str; GList *list; gboolean ignore_newlines = FALSE; g_return_if_fail (EMPATHY_IS_CHAT_TEXT_VIEW (view)); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); if (!gtk_text_buffer_get_selection_bounds (buffer, &start, &end)) return; str = g_string_new (""); for (iter = start; !gtk_text_iter_equal (&iter, &end); gtk_text_iter_forward_char (&iter)) { c = gtk_text_iter_get_char (&iter); /* 0xFFFC is the 'object replacement' unicode character, * it indicates the presence of a pixbuf or a widget. */ if (c == 0xFFFC) { ignore_newlines = FALSE; if ((pixbuf = gtk_text_iter_get_pixbuf (&iter))) { gchar *text; text = g_object_get_data (G_OBJECT(pixbuf), "smiley_str"); if (text) str = g_string_append (str, text); } else if ((anchor = gtk_text_iter_get_child_anchor (&iter))) { gchar *text; list = gtk_text_child_anchor_get_widgets (anchor); if (list) { text = g_object_get_data (G_OBJECT(list->data), "str_obj"); if (text) str = g_string_append (str, text); } g_list_free (list); } } else if (c == '\n') { if (!ignore_newlines) { ignore_newlines = TRUE; str = g_string_append_unichar (str, c); } } else { ignore_newlines = FALSE; str = g_string_append_unichar (str, c); } } gtk_clipboard_set_text (clipboard, str->str, str->len); g_string_free (str, TRUE); }
JNIEXPORT jlongArray JNICALL Java_org_gnome_gtk_GtkTextChildAnchor_gtk_1text_1child_1anchor_1get_1widgets ( JNIEnv* env, jclass cls, jlong _self ) { GList* result; jlongArray _result; GtkTextChildAnchor* self; // convert parameter self self = (GtkTextChildAnchor*) _self; // call function result = gtk_text_child_anchor_get_widgets(self); // cleanup parameter self // translate return value to JNI type _result = (jlongArray) bindings_java_convert_glist_to_jarray(env, result); // cleanup return value if (result != NULL) { g_list_free(result); } // and finally return _result; }
CAMLprim value ml_gtk_text_child_anchor_get_widgets (value tca) { return Val_GList_free (gtk_text_child_anchor_get_widgets(GtkTextChildAnchor_val(tca)), Val_GtkWidget_func); }
static VALUE textchild_get_widgets(VALUE self) { return GLIST2ARYF(gtk_text_child_anchor_get_widgets(_SELF(self))); }