Re: GTK3 porting problem (clipboard)



You're right, but this seems odd. In the GTK3 version of the
documentation the basic structures GtkTargetEntry and
GtkTargetPair are still exposed in the API, and although
GtkTargetList is said to be opaque (a) it's unclear why this
should be so (it seems to be a trivial composite) and (b) the
functionality that was previously available via the struct itself
is not replicated via accessor functions. For example, there's no

gtk_target_list_get_n_targets()

to replace the original poster's GTK2 idiom:

int nTargetCnt = g_list_length (list->list);

Perhaps someone knows any workaround for what I am trying to do in my code or a way to implement this differently?

The code does the following:

//create a target list with text and HTML formats
GtkTargetList *list = gtk_target_list_new (NULL, 0);
gtk_target_list_add(list, atomTextHtml, 0, 0);
gtk_target_list_add_text_targets(list, 0);

//now I need to convert the target list to an array of the GtkTargetEntry structures as needed by gtk_clipboard_set_with_data
int nTargetCnt = g_list_length (list->list);
GtkTargetEntry *targets = g_new0 (GtkTargetEntry, nTargetCnt);
int i=0;
for (GList *l=list->list; l; l=l->next, i++)
{
GtkTargetPair *pair = (GtkTargetPair *)l->data;
targets[i].target = gdk_atom_name (pair->target);
}

//set the clipboard with target formats
gboolean bOK = gtk_clipboard_set_with_data(clipboard, targets, nTargetCnt, MyGtkClipboardGetFunc, NULL, 0);

Basically the big problem is that gtk_clipboard_set_with_data API does not use GtktargetList directly.

Regards,
Miroslav



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]