static gboolean font_fetch(void) { gchar *font_name; font_name = g_strdup(gtk_font_selection_get_font_name( GTK_FONT_SELECTION(font_browse_w))); if (font_name == NULL) { /* No font was selected; let the user know, but don't tear down the font selection dialog, so they can try again. */ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "You have not selected a font."); return FALSE; } if (!user_font_test(font_name)) { /* The font isn't usable; "user_font_test()" has already told the user why. Don't tear down the font selection dialog. */ g_free(font_name); return FALSE; } new_font_name = font_name; return TRUE; }
/* * Writes the source code needed to create this widget. * You have to output everything necessary to create the widget here, though * there are some convenience functions to help. */ static void gb_font_selection_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data) { const gchar *preview_text; if (data->create_widget) { source_add (data, " %s = gtk_font_selection_new ();\n", data->wname); } gb_widget_write_standard_source (widget, data); preview_text = gtk_font_selection_get_preview_text (GTK_FONT_SELECTION (widget)); if (strcmp (preview_text, DEFAULT_PREVIEW_TEXT)) { gboolean translatable, context; gchar *comments; glade_util_get_translation_properties (widget, PreviewText, &translatable, &comments, &context); source_add_translator_comments (data, translatable, comments); source_add (data, " gtk_font_selection_set_preview_text (GTK_FONT_SELECTION (%s), %s);\n", data->wname, source_make_string_full (preview_text, data->use_gettext && translatable, context)); } }
static void load_font(GtkWidget *widget, GtkPrintOperation *prt) { gchar *fontname = g_object_get_data(G_OBJECT(prt),"3270FontName"); Trace("Loading font \"%s\"",fontname); gtk_font_selection_set_font_name(GTK_FONT_SELECTION(widget),fontname); if(!gtk_font_selection_get_size(GTK_FONT_SELECTION(widget))) { // Font size is 0, set it to 10 gchar *ptr = g_strdup_printf("%s 10",fontname); gtk_font_selection_set_font_name(GTK_FONT_SELECTION(widget),ptr); g_free(ptr); } }
/* * Gets the properties of the widget. This is used for both displaying the * properties in the property editor, and also for saving the properties. */ static void gb_font_selection_get_properties (GtkWidget *widget, GbWidgetGetArgData * data) { const gchar *preview_text; preview_text = gtk_font_selection_get_preview_text (GTK_FONT_SELECTION (widget)); gb_widget_output_translatable_string (data, PreviewText, preview_text); }
void font_print_result (void) { if (options.font_data.separate_output) { PangoFontFace *face; PangoFontFamily *family; gint size; face = gtk_font_selection_get_face (GTK_FONT_SELECTION (font)); family = gtk_font_selection_get_family (GTK_FONT_SELECTION (font)); size = gtk_font_selection_get_size (GTK_FONT_SELECTION (font)); if (options.common_data.quoted_output) { gchar *q1 = g_shell_quote (pango_font_family_get_name (family)); gchar *q2 = g_shell_quote (pango_font_face_get_face_name (face)); g_printf ("%s%s%s%s%d\n", q1, options.common_data.separator, q2, options.common_data.separator, size / 1000); g_free (q1); g_free (q2); } else { g_printf ("%s%s%s%s%d\n", pango_font_family_get_name (family), options.common_data.separator, pango_font_face_get_face_name (face), options.common_data.separator, size / 1000); } } else { gchar *fn = gtk_font_selection_get_font_name (GTK_FONT_SELECTION (font)); if (options.common_data.quoted_output) { gchar *buf = g_shell_quote (fn); g_printf ("%s\n", buf); g_free (buf); } else g_printf ("%s\n", fn); g_free (fn); } }
void update_font (GtkWidget * crap) { if (fntname) g_free (fntname); fntname = g_strdup (gtk_font_selection_get_font_name (GTK_FONT_SELECTION (blah))); return; }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_font_selection_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gchar *preview_text; preview_text = gb_widget_input_string (data, PreviewText); if (data->apply) gtk_font_selection_set_preview_text (GTK_FONT_SELECTION (widget), preview_text); }
/* Gets the text displayed in the preview area. */ int clip_GTK_FONTSELECTIONGETPREVIEWTEXT(ClipMachine * ClipMachineMemory) { C_widget *cfsel = _fetch_cw_arg(ClipMachineMemory); CHECKCWID(cfsel, GTK_IS_FONT_SELECTION); _clip_retc(ClipMachineMemory, gtk_font_selection_get_preview_text(GTK_FONT_SELECTION(cfsel->widget))); return 0; err: return 1; }
/* Gets the currently-selected font name. */ int clip_GTK_FONTSELECTIONGETFONTNAME(ClipMachine * ClipMachineMemory) { C_widget *cfsel = _fetch_cw_arg(ClipMachineMemory); CHECKCWID(cfsel, GTK_IS_FONT_SELECTION); _clip_retc(ClipMachineMemory, gtk_font_selection_get_font_name(GTK_FONT_SELECTION(cfsel->widget))); return 0; err: return 1; }
static void custom_widget_apply(GtkPrintOperation *prt, GtkWidget *font_dialog, gpointer user_data) { gchar *font = NULL; #if GTK_CHECK_VERSION(2,20,0) if(gtk_widget_get_realized(font_dialog)) #else if(GTK_WIDGET_REALIZED(font_dialog)) #endif font = gtk_font_selection_get_font_name(GTK_FONT_SELECTION(font_dialog)); Trace("Selected font: \"%s\"",font); if(font) g_object_set_data_full(G_OBJECT(prt),"3270FontName",font,g_free); }
/* Sets the currently-selected font. */ int clip_GTK_FONTSELECTIONSETFONTNAME(ClipMachine * ClipMachineMemory) { C_widget *cfsel = _fetch_cw_arg(ClipMachineMemory); gchar *font_name = _clip_parc(ClipMachineMemory, 2); CHECKCWID(cfsel, GTK_IS_FONT_SELECTION); CHECKOPT(2, CHARACTER_type_of_ClipVarType); if (_clip_parinfo(ClipMachineMemory, 2) == UNDEF_type_of_ClipVarType) font_name = "\0"; _clip_retl(ClipMachineMemory, gtk_font_selection_set_font_name(GTK_FONT_SELECTION(cfsel->widget), font_name)); return 0; err: return 1; }
void conffont () { if (blah) { if (this_panel_cb) this_panel_cb (); gtk_widget_destroy (blah); } blah = gtk_font_selection_new (); gtk_font_selection_set_font_name (GTK_FONT_SELECTION (blah), fntname); gtk_widget_show (blah); gtk_box_pack_start (GTK_BOX (hbox), blah, 0, 0, 2); this_panel_cb = update_font; return; }
GtkWidget * font_create_widget (GtkWidget * dlg) { GtkWidget *w; w = font = gtk_font_selection_new (); gtk_widget_set_name (w, "yad-font-widget"); if (options.font_data.preview) gtk_font_selection_set_preview_text (GTK_FONT_SELECTION (w), options.font_data.preview); /* font must be set after widget inserted in toplevel */ if (options.common_data.font) g_signal_connect_after (G_OBJECT (w), "realize", G_CALLBACK (realize_cb), NULL); return w; }
int main (int argc, char *argv[]) { GtkWidget *window; GtkWidget *hbox; GtkWidget *fontsel; gtk_init (NULL, NULL); fontsel = gtk_font_selection_new (); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_size_request (window, 600, 600); hbox = gtk_hbox_new (FALSE, 6); gtk_container_add (GTK_CONTAINER (window), hbox); #ifndef GTK_DISABLE_DEPRECATED g_object_ref (gtk_font_selection_get_size_list (GTK_FONT_SELECTION (fontsel))); g_object_ref (gtk_font_selection_get_family_list (GTK_FONT_SELECTION (fontsel))); g_object_ref (gtk_font_selection_get_face_list (GTK_FONT_SELECTION (fontsel))); gtk_container_add (GTK_CONTAINER (hbox), gtk_font_selection_get_size_list (GTK_FONT_SELECTION (fontsel))); gtk_container_add (GTK_CONTAINER (hbox), gtk_font_selection_get_family_list (GTK_FONT_SELECTION (fontsel))); gtk_container_add (GTK_CONTAINER (hbox), gtk_font_selection_get_face_list (GTK_FONT_SELECTION (fontsel))); #endif gtk_container_add (GTK_CONTAINER (hbox), fontsel); gtk_widget_show_all (window); g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK(gtk_main_quit), NULL); g_signal_connect (G_OBJECT (fontsel), "notify::font-name", G_CALLBACK(notify_font_name_cb), NULL); g_signal_connect (G_OBJECT (fontsel), "notify::preview-text", G_CALLBACK(notify_preview_text_cb), NULL); gtk_font_selection_set_font_name (GTK_FONT_SELECTION (fontsel), "Bitstream Vera Sans 45"); gtk_font_selection_set_preview_text (GTK_FONT_SELECTION (fontsel), "[user@host ~]$ "); gtk_main (); gtk_widget_destroy (window); return 0; }
/* Sets the text displayed in the preview area. */ int clip_GTK_FONTSELECTIONSETPREVIEWTEXT(ClipMachine * ClipMachineMemory) { C_widget *cfsel = _fetch_cw_arg(ClipMachineMemory); gchar *preview_text = _clip_parc(ClipMachineMemory, 2); CHECKCWID(cfsel, GTK_IS_FONT_SELECTION); CHECKOPT(2, CHARACTER_type_of_ClipVarType); if (_clip_parinfo(ClipMachineMemory, 2) == UNDEF_type_of_ClipVarType) preview_text = "\0"; LOCALE_TO_UTF(preview_text); gtk_font_selection_set_preview_text(GTK_FONT_SELECTION(cfsel->widget), preview_text); FREE_TEXT(preview_text); return 0; err: return 1; }
/* Does not work as expected yet. Need to know how to make it return XLFD. */ void gui_dialog_show_fontchooser(GtkWidget * txt_entry) { GtkWidget *font_selector = NULL; GGaduKeyValue *kv = (GGaduKeyValue *) g_object_get_data(G_OBJECT(txt_entry), "kv"); gchar *font_name = NULL; gint response; font_selector = gtk_font_selection_dialog_new(_("Select font")); response = gtk_dialog_run(GTK_DIALOG(font_selector)); if (response == GTK_RESPONSE_OK) { font_name = (gchar *) gtk_font_selection_get_font_name(GTK_FONT_SELECTION(GTK_FONT_SELECTION_DIALOG(font_selector)->fontsel)); gtk_entry_set_text(GTK_ENTRY(txt_entry), font_name); kv->value = (gpointer) font_name; } gtk_widget_destroy(font_selector); }
static void font_ok_sel( GtkWidget *widget, gpointer cb_data ) { PXWT_GTK_MODAL xwtFilew = (PXWT_GTK_MODAL) ((PXWT_WIDGET)cb_data)->widget_data; HB_ITEM itmFileName; const char *fname; // this builds the Self object // If you use this macro, you must put it AFTER variable decl, // and BEFORE any other statement XWT_GTK_MAKESELF( (((PXWT_WIDGET)cb_data)->owner) ); fname = gtk_font_selection_dialog_get_font_name( GTK_FONT_SELECTION( xwtFilew->a.main_widget ) ); // itemPutC uses the char* parameter as it were const: it does not // mangles with that, it just creates a new local copy of the param. hb_itemPutC( &itmFileName, ( char *) fname ); //rising the updated event, to signal that we have a candidate filename xwt_rise_event( &Self, XWT_E_UPDATED, 1, &itmFileName ); // now we can reset the modal status xwtFilew->modal = FALSE; }
/* Gets the currently-selected font. */ int clip_GTK_FONTSELECTIONGETFONT(ClipMachine * ClipMachineMemory) { C_widget *cfsel = _fetch_cw_arg(ClipMachineMemory); C_object *cfont; GdkFont *font; CHECKCWID(cfsel, GTK_IS_FONT_SELECTION); font = gtk_font_selection_get_font(GTK_FONT_SELECTION(cfsel->widget)); if (!font) return 0; cfont = _list_get_cobject(ClipMachineMemory, font); if (!cfont) cfont = _register_object(ClipMachineMemory, font, GDK_OBJECT_FONT, NULL, (coDestructor) gdk_object_font_destructor); if (cfont) _clip_mclone(ClipMachineMemory, RETPTR(ClipMachineMemory), &cfont->obj); return 0; err: return 1; }
/* * fontsel : a GtkFontSelection. * filter_type : which of the two font filters to set, either GTK_FONT_FILTER_BASE or * GTK_FONT_FILTER_USER. The user filter can be changed by the user, but * the base filter is permanent. * font_type : the types of font to be shown. This is a bitwise combination of * GTK_FONT_BITMAP, GTK_FONT_SCALABLE and GTK_FONT_SCALABLE_BITMAP, or * GTK_FONT_ALL to show all three font types. * foundries : a NULL-terminated array of strings containing foundry names which * will be shown, or NULL to show all foundries. * weights : a NULL-terminated array of strings containing weight names which * will be shown, or NULL to show all weights. * slants : a NULL-terminated array of strings containing slant names which will * be shown, or NULL to show all slants. * setwidths : a NULL-terminated array of strings containing setwidth names which * will be shown, or NULL to show all setwidths. * spacings : a NULL-terminated array of strings containing spacings which will be * shown, or NULL to show all spacings. * charsets : a NULL-terminated array of strings containing charset names which will * be shown, or NULL to show all charsets. */ int clip_GTK_FONTSELECTIONSETFILTER(ClipMachine * ClipMachineMemory) { C_widget *cfsel = _fetch_cw_arg(ClipMachineMemory); int filter_type = _clip_parni(ClipMachineMemory, 2); int font_type = _clip_parni(ClipMachineMemory, 3); ClipVar *cv_foundries = _clip_spar(ClipMachineMemory, 4); ClipVar *cv_weights = _clip_spar(ClipMachineMemory, 5); ClipVar *cv_slants = _clip_spar(ClipMachineMemory, 6); ClipVar *cv_setwidths = _clip_spar(ClipMachineMemory, 7); ClipVar *cv_spacings = _clip_spar(ClipMachineMemory, 8); ClipVar *cv_charsets = _clip_spar(ClipMachineMemory, 9); gchar **foundries, **weights, **slants, **setwidths, **spacings, **charsets; int i; ClipArrVar *a; CHECKCWID(cfsel, GTK_IS_FONT_SELECTION); CHECKOPT(2, NUMERIC_type_of_ClipVarType); CHECKOPT(3, NUMERIC_type_of_ClipVarType); if (_clip_parinfo(ClipMachineMemory, 2) == UNDEF_type_of_ClipVarType) filter_type = GTK_FONT_FILTER_BASE; if (_clip_parinfo(ClipMachineMemory, 3) == UNDEF_type_of_ClipVarType) font_type = GTK_FONT_ALL; switch (cv_foundries->ClipType_t_of_ClipVar.ClipVartype_type_of_ClipType) { case CHARACTER_type_of_ClipVarType: foundries = (gchar **) calloc(sizeof(*foundries), 2); foundries[0] = cv_foundries->ClipStrVar_s_of_ClipVar.ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf; break; case ARRAY_type_of_ClipVarType: a = (ClipArrVar *) _clip_vptr(cv_foundries); foundries = (gchar **) calloc(sizeof(*foundries), a->count_of_ClipArrVar + 1); for (i = 0; i < a->count_of_ClipArrVar; i++) foundries[i] = a->ClipVar_items_of_ClipArrVar[i].ClipStrVar_s_of_ClipVar.ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf; default: foundries = NULL; } switch (cv_weights->ClipType_t_of_ClipVar.ClipVartype_type_of_ClipType) { case CHARACTER_type_of_ClipVarType: weights = (gchar **) calloc(sizeof(*weights), 2); weights[0] = cv_weights->ClipStrVar_s_of_ClipVar.ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf; break; case ARRAY_type_of_ClipVarType: a = (ClipArrVar *) _clip_vptr(cv_weights); weights = (gchar **) calloc(sizeof(*weights), a->count_of_ClipArrVar + 1); for (i = 0; i < a->count_of_ClipArrVar; i++) weights[i] = a->ClipVar_items_of_ClipArrVar[i].ClipStrVar_s_of_ClipVar.ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf; default: weights = NULL; } switch (cv_slants->ClipType_t_of_ClipVar.ClipVartype_type_of_ClipType) { case CHARACTER_type_of_ClipVarType: slants = (gchar **) calloc(sizeof(*slants), 2); slants[0] = cv_slants->ClipStrVar_s_of_ClipVar.ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf; break; case ARRAY_type_of_ClipVarType: a = (ClipArrVar *) _clip_vptr(cv_slants); slants = (gchar **) calloc(sizeof(*slants), a->count_of_ClipArrVar + 1); for (i = 0; i < a->count_of_ClipArrVar; i++) slants[i] = a->ClipVar_items_of_ClipArrVar[i].ClipStrVar_s_of_ClipVar.ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf; default: slants = NULL; } switch (cv_setwidths->ClipType_t_of_ClipVar.ClipVartype_type_of_ClipType) { case CHARACTER_type_of_ClipVarType: setwidths = (gchar **) calloc(sizeof(*setwidths), 2); setwidths[0] = cv_setwidths->ClipStrVar_s_of_ClipVar.ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf; break; case ARRAY_type_of_ClipVarType: a = (ClipArrVar *) _clip_vptr(cv_setwidths); setwidths = (gchar **) calloc(sizeof(*setwidths), a->count_of_ClipArrVar + 1); for (i = 0; i < a->count_of_ClipArrVar; i++) setwidths[i] = a->ClipVar_items_of_ClipArrVar[i].ClipStrVar_s_of_ClipVar.ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf; default: setwidths = NULL; } switch (cv_spacings->ClipType_t_of_ClipVar.ClipVartype_type_of_ClipType) { case CHARACTER_type_of_ClipVarType: spacings = (gchar **) calloc(sizeof(*spacings), 2); spacings[0] = cv_spacings->ClipStrVar_s_of_ClipVar.ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf; break; case ARRAY_type_of_ClipVarType: a = (ClipArrVar *) _clip_vptr(cv_spacings); spacings = (gchar **) calloc(sizeof(*spacings), a->count_of_ClipArrVar + 1); for (i = 0; i < a->count_of_ClipArrVar; i++) spacings[i] = a->ClipVar_items_of_ClipArrVar[i].ClipStrVar_s_of_ClipVar.ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf; default: spacings = NULL; } switch (cv_charsets->ClipType_t_of_ClipVar.ClipVartype_type_of_ClipType) { case CHARACTER_type_of_ClipVarType: charsets = (gchar **) calloc(sizeof(*charsets), 2); charsets[0] = cv_charsets->ClipStrVar_s_of_ClipVar.ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf; break; case ARRAY_type_of_ClipVarType: a = (ClipArrVar *) _clip_vptr(cv_charsets); charsets = (gchar **) calloc(sizeof(*charsets), a->count_of_ClipArrVar + 1); for (i = 0; i < a->count_of_ClipArrVar; i++) charsets[i] = a->ClipVar_items_of_ClipArrVar[i].ClipStrVar_s_of_ClipVar.ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf; default: charsets = NULL; } CHECKOPT2(4, ARRAY_type_of_ClipVarType, CHARACTER_type_of_ClipVarType); CHECKOPT2(5, ARRAY_type_of_ClipVarType, CHARACTER_type_of_ClipVarType); CHECKOPT2(6, ARRAY_type_of_ClipVarType, CHARACTER_type_of_ClipVarType); CHECKOPT2(7, ARRAY_type_of_ClipVarType, CHARACTER_type_of_ClipVarType); CHECKOPT2(8, ARRAY_type_of_ClipVarType, CHARACTER_type_of_ClipVarType); CHECKOPT2(9, ARRAY_type_of_ClipVarType, CHARACTER_type_of_ClipVarType); gtk_font_selection_set_filter(GTK_FONT_SELECTION(cfsel->widget), filter_type, font_type, foundries, weights, slants, setwidths, spacings, charsets); if (foundries) free(foundries); if (weights) free(weights); if (slants) free(slants); if (setwidths) free(setwidths); if (spacings) free(spacings); if (charsets) free(charsets); return 0; err: return 1; }
static void notify_font_name_cb (GObject *fontsel, GParamSpec *pspec, gpointer data) { g_debug ("Changed font name %s", gtk_font_selection_get_font_name (GTK_FONT_SELECTION (fontsel))); }
static void realize_cb (GtkWidget * w, gpointer d) { gtk_font_selection_set_font_name (GTK_FONT_SELECTION (w), options.common_data.font); }
static void notify_preview_text_cb (GObject *fontsel, GParamSpec *pspec, gpointer data) { g_debug ("Changed preview text %s", gtk_font_selection_get_preview_text (GTK_FONT_SELECTION (fontsel))); }