Re: Convenience APIs for selections
- From: Jody Goldberg <jody gnome org>
- To: Federico Mena Quintero <federico ximian com>
- Cc: GTK+ development mailing list <gtk-devel-list gnome org>
- Subject: Re: Convenience APIs for selections
- Date: Fri, 23 Apr 2004 11:52:12 -0400
On Thu, Apr 15, 2004 at 12:32:42PM -0500, Federico Mena Quintero wrote:
>
> /* Sets "application/x-color" from the 16-bit RGB values */
> void gtk_selection_data_set_color (GtkSelectionData *data,
> const GdkColor *color);
> /* Parses from "application/x-color", handling old KDE's broken
> * colors. Returns an error if the selection type doesn't have
> * the right atom or if parsing fails.
> */
> gboolean gtk_selection_data_get_color (GtkSelectionData *data,
> GdkColor *color,
> GError **error);
* type: application/x-color
* format::16
* data[0]: red
* data[1]: green
* data[2]: blue
* data[3]: opacity
Looks like we'd want
GdkColor *color, guint16 *alpha
> /* Parses "text/uri-list". Returns a list of char *. Returns an
> * error if the selection type doesn't have the right atom
> * or if parsing fails.
> */
> gboolean gtk_selection_data_get_uri_list (GtkSelectionData *data,
> GList **uri_list,
> GError **error);
Docs should be clear on 'char *' vs 'const char *' who needs to free
those strings ?
> if (gtk_selection_data_is_color (selection_data))
> {
> GdkColor color;
> GError *error;
>
> error = NULL;
> if (!gtk_selection_data_get_color (selection_data, &color, &error))
> {
> g_print ("broken color: %s", error->message);
> g_error_free (error);
> }
> else
> do_something_with_color (&color);
> }
Why not combine the two operations
if (gtk_selection_data_is_color (selection_data, &color, &alpha))
do_stuff
why should an application care if something is sending invalid
clipboard data ? Let the toolkit handle it.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]