static int gtkDialogSetTitleAttrib(Ihandle* ih, const char* value) { if (!value) value = ""; gtk_window_set_title((GtkWindow*)ih->handle, iupgtkStrConvertToSystem(value)); return 1; }
static int gtkFrameSetTitleAttrib(Ihandle* ih, const char* value) { if (iupAttribGetStr(ih, "_IUPFRAME_HAS_TITLE")) { GtkFrame* frame = (GtkFrame*)ih->handle; gtk_frame_set_label(frame, iupgtkStrConvertToSystem(value)); return 1; } return 0; }
static int gtkMessageDlgPopup(Ihandle* ih, int x, int y) { InativeHandle* parent = iupDialogGetNativeParent(ih); GtkMessageType type = GTK_MESSAGE_OTHER; GtkWidget* dialog; char *icon, *buttons, *title; const char *ok, *cancel, *yes, *no, *help, *retry = IupGetLanguageString("IUP_RETRY"); int response, button_def; iupAttribSetInt(ih, "_IUPDLG_X", x); /* used in iupDialogUpdatePosition */ iupAttribSetInt(ih, "_IUPDLG_Y", y); icon = iupAttribGetStr(ih, "DIALOGTYPE"); if (iupStrEqualNoCase(icon, "ERROR")) type = GTK_MESSAGE_ERROR; else if (iupStrEqualNoCase(icon, "WARNING")) type = GTK_MESSAGE_WARNING; else if (iupStrEqualNoCase(icon, "INFORMATION")) type = GTK_MESSAGE_INFO; else if (iupStrEqualNoCase(icon, "QUESTION")) type = GTK_MESSAGE_QUESTION; dialog = gtk_message_dialog_new((GtkWindow*)parent, 0, type, GTK_BUTTONS_NONE, "%s", iupgtkStrConvertToSystem(iupAttribGet(ih, "VALUE"))); if (!dialog) return IUP_ERROR; title = iupAttribGet(ih, "TITLE"); if (title) gtk_window_set_title(GTK_WINDOW(dialog), iupgtkStrConvertToSystem(title)); #if GTK_CHECK_VERSION(3, 10, 0) ok = "_OK"; cancel = "_Cancel"; yes = "_Yes"; no = "_No"; help = "_Help"; #else ok = GTK_STOCK_OK; cancel = GTK_STOCK_CANCEL; yes = GTK_STOCK_YES; no = GTK_STOCK_NO; help = GTK_STOCK_HELP; #endif buttons = iupAttribGetStr(ih, "BUTTONS"); if (iupStrEqualNoCase(buttons, "OKCANCEL")) { gtk_dialog_add_button(GTK_DIALOG(dialog), ok, IUP_RESPONSE_1); gtk_dialog_add_button(GTK_DIALOG(dialog), cancel, IUP_RESPONSE_2); } if (iupStrEqualNoCase(buttons, "RETRYCANCEL")) { gtk_dialog_add_button(GTK_DIALOG(dialog), retry, IUP_RESPONSE_1); gtk_dialog_add_button(GTK_DIALOG(dialog), cancel, IUP_RESPONSE_2); } else if (iupStrEqualNoCase(buttons, "YESNO")) { gtk_dialog_add_button(GTK_DIALOG(dialog), yes, IUP_RESPONSE_1); gtk_dialog_add_button(GTK_DIALOG(dialog), no, IUP_RESPONSE_2); } else if (iupStrEqualNoCase(buttons, "YESNOCANCEL")) { gtk_dialog_add_button(GTK_DIALOG(dialog), yes, IUP_RESPONSE_1); gtk_dialog_add_button(GTK_DIALOG(dialog), no, IUP_RESPONSE_2); gtk_dialog_add_button(GTK_DIALOG(dialog), cancel, IUP_RESPONSE_3); } else /* OK */ { gtk_dialog_add_button(GTK_DIALOG(dialog), ok, IUP_RESPONSE_1); } if (IupGetCallback(ih, "HELP_CB")) gtk_dialog_add_button(GTK_DIALOG(dialog), help, IUP_RESPONSE_HELP); button_def = iupAttribGetInt(ih, "BUTTONDEFAULT"); if (button_def == 3) gtk_dialog_set_default_response(GTK_DIALOG(dialog), IUP_RESPONSE_3); else if (button_def == 2) gtk_dialog_set_default_response(GTK_DIALOG(dialog), IUP_RESPONSE_2); else gtk_dialog_set_default_response(GTK_DIALOG(dialog), IUP_RESPONSE_1); /* initialize the widget */ gtk_widget_realize(dialog); ih->handle = dialog; iupDialogUpdatePosition(ih); ih->handle = NULL; do { response = gtk_dialog_run(GTK_DIALOG(dialog)); if (response == IUP_RESPONSE_HELP) { Icallback cb = IupGetCallback(ih, "HELP_CB"); if (cb && cb(ih) == IUP_CLOSE) { if (iupStrEqualNoCase(buttons, "YESNOCANCEL")) response = IUP_RESPONSE_3; else if(iupStrEqualNoCase(buttons, "OK")) response = IUP_RESPONSE_1; else response = IUP_RESPONSE_2; } } } while (response == IUP_RESPONSE_HELP); if (response == IUP_RESPONSE_3) IupSetAttribute(ih, "BUTTONRESPONSE", "3"); else if (response == IUP_RESPONSE_2) IupSetAttribute(ih, "BUTTONRESPONSE", "2"); else IupSetAttribute(ih, "BUTTONRESPONSE", "1"); gtk_widget_destroy(dialog); return IUP_NOERROR; }
static int gtkFontDlgPopup(Ihandle* ih, int x, int y) { InativeHandle* parent = iupDialogGetNativeParent(ih); GtkWidget* dialog; int response; char* preview_text, *standardfont; iupAttribSetInt(ih, "_IUPDLG_X", x); /* used in iupDialogUpdatePosition */ iupAttribSetInt(ih, "_IUPDLG_Y", y); #if GTK_CHECK_VERSION(3, 2, 0) dialog = gtk_font_chooser_dialog_new(iupgtkStrConvertToSystem(iupAttribGet(ih, "TITLE")), GTK_WINDOW(parent)); #else dialog = gtk_font_selection_dialog_new(iupgtkStrConvertToSystem(iupAttribGet(ih, "TITLE"))); #endif if (!dialog) return IUP_ERROR; #if !GTK_CHECK_VERSION(3, 2, 0) if (parent) gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(parent)); #endif standardfont = iupAttribGet(ih, "VALUE"); if (!standardfont) standardfont = IupGetGlobal("DEFAULTFONT"); #if GTK_CHECK_VERSION(3, 2, 0) gtk_font_chooser_set_font(GTK_FONT_CHOOSER(dialog), standardfont); #else gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(dialog), standardfont); #endif preview_text = iupAttribGet(ih, "PREVIEWTEXT"); if (preview_text) { preview_text = iupgtkStrConvertToSystem(preview_text); #if GTK_CHECK_VERSION(3, 2, 0) if (iupStrEqualNoCase(preview_text, "NONE")) gtk_font_chooser_set_show_preview_entry(GTK_FONT_CHOOSER(dialog), FALSE); else gtk_font_chooser_set_preview_text(GTK_FONT_CHOOSER(dialog), preview_text); #else gtk_font_selection_dialog_set_preview_text(GTK_FONT_SELECTION_DIALOG(dialog), preview_text); #endif } if (IupGetCallback(ih, "HELP_CB")) { #if GTK_CHECK_VERSION(3, 10, 0) const char* help = "_Help"; #else const char* help = GTK_STOCK_HELP; #endif gtk_dialog_add_button(GTK_DIALOG(dialog), help, GTK_RESPONSE_HELP); } /* 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) { #if GTK_CHECK_VERSION(3, 2, 0) char* fontname = gtk_font_chooser_get_font(GTK_FONT_CHOOSER(dialog)); #else char* fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(dialog)); #endif iupAttribSetStr(ih, "VALUE", fontname); g_free(fontname); iupAttribSet(ih, "STATUS", "1"); } else { iupAttribSet(ih, "VALUE", NULL); iupAttribSet(ih, "STATUS", NULL); } gtk_widget_destroy(GTK_WIDGET(dialog)); return IUP_NOERROR; }
static int gtkWebBrowserSetHTMLAttrib(Ihandle* ih, const char* value) { if (value) webkit_web_view_load_string((WebKitWebView*)ih->handle, iupgtkStrConvertToSystem(value), "text/html", "UTF-8", ""); return 0; /* do not store value in hash table */ }