int clip_GTK_COLORSELECTIONGETHASPALETTE(ClipMachine * ClipMachineMemory) { C_widget *ccsel = _fetch_cw_arg(ClipMachineMemory); CHECKCWID(ccsel, GTK_IS_COLOR_SELECTION); _clip_retl(ClipMachineMemory, gtk_color_selection_get_has_palette(GTK_COLOR_SELECTION(ccsel->widget))); return 0; err: return 1; }
static int gtkColorDlgPopup(Ihandle* ih, int x, int y) { InativeHandle* parent = iupDialogGetNativeParent(ih); GtkColorSelectionDialog* dialog; GtkColorSelection* colorsel; GdkColor color; char *value; unsigned char r = 0, g = 0, b = 0, a = 255; int response, ret; iupAttribSetInt(ih, "_IUPDLG_X", x); /* used in iupDialogUpdatePosition */ iupAttribSetInt(ih, "_IUPDLG_Y", y); dialog = (GtkColorSelectionDialog*)gtk_color_selection_dialog_new(iupgtkStrConvertToUTF8(iupAttribGet(ih, "TITLE"))); if (!dialog) return IUP_ERROR; if (parent) gtk_window_set_transient_for((GtkWindow*)dialog, (GtkWindow*)parent); ret = iupStrToRGBA(iupAttribGet(ih, "VALUE"), &r, &g, &b, &a); colorsel = (GtkColorSelection*)dialog->colorsel; iupgdkColorSet(&color, r, g, b); gtk_color_selection_set_current_color(colorsel, &color); value = iupAttribGetStr(ih, "ALPHA"); if (value) { int alpha; if (iupStrToInt(value, &alpha)) { if (alpha<0) alpha=0; if (alpha>255) alpha=255; gtk_color_selection_set_has_opacity_control(colorsel, TRUE); gtk_color_selection_set_current_alpha(colorsel, iupCOLOR8TO16(alpha)); } } else if (iupAttribGetBoolean(ih, "SHOWALPHA") || ret == 4) { gtk_color_selection_set_has_opacity_control(colorsel, TRUE); gtk_color_selection_set_current_alpha(colorsel, iupCOLOR8TO16(a)); } else gtk_color_selection_set_has_opacity_control(colorsel, FALSE); value = iupAttribGetStr(ih, "COLORTABLE"); if (value) { gtk_color_selection_set_has_palette (colorsel, TRUE); gtkColorDlgSetPalette(colorsel, value); } else if (iupAttribGetBoolean(ih, "SHOWCOLORTABLE")) gtk_color_selection_set_has_palette (colorsel, TRUE); else gtk_color_selection_set_has_palette (colorsel, FALSE); if (IupGetCallback(ih, "HELP_CB")) gtk_widget_show(dialog->help_button); /* initialize the widget */ gtk_widget_realize(GTK_WIDGET(dialog)); ih->handle = GTK_WIDGET(dialog); iupDialogUpdatePosition(ih); ih->handle = NULL; do { response = gtk_dialog_run(GTK_DIALOG(dialog)); if (response == GTK_RESPONSE_HELP) { Icallback cb = IupGetCallback(ih, "HELP_CB"); if (cb && cb(ih) == IUP_CLOSE) response = GTK_RESPONSE_CANCEL; } } while (response == GTK_RESPONSE_HELP); if (response == GTK_RESPONSE_OK) { GdkColor color; gtk_color_selection_get_current_color(colorsel, &color); IupSetAttribute(ih, "STATUS", "1"); if (gtk_color_selection_get_has_opacity_control(colorsel)) { int alpha = gtk_color_selection_get_current_alpha(colorsel); iupAttribSetInt(ih, "ALPHA", (int)iupCOLOR16TO8(alpha)); iupAttribSetStrf(ih, "VALUE", "%d %d %d %d", (int)iupCOLOR16TO8(color.red), (int)iupCOLOR16TO8(color.green), (int)iupCOLOR16TO8(color.blue), (int)iupCOLOR16TO8(alpha)); } else iupAttribSetStrf(ih, "VALUE", "%d %d %d", (int)iupCOLOR16TO8(color.red), (int)iupCOLOR16TO8(color.green), (int)iupCOLOR16TO8(color.blue)); if (gtk_color_selection_get_has_palette(colorsel)) gtkColorDlgGetPalette(ih, colorsel); } else { iupAttribSetStr(ih, "ALPHA", NULL); iupAttribSetStr(ih, "VALUE", NULL); iupAttribSetStr(ih, "COLORTABLE", NULL); iupAttribSetStr(ih, "STATUS", NULL); } gtk_widget_destroy(GTK_WIDGET(dialog)); return IUP_NOERROR; }