Beispiel #1
0
void select_font(GtkWidget *widget, gpointer label)
{
	GtkResponseType result;

	GtkWidget *dialog = gtk_font_selection_dialog_new("Select Font");
	result = gtk_dialog_run(GTK_DIALOG(dialog));

	if( result == GTK_RESPONSE_OK || result == GTK_RESPONSE_APPLY)
	{
		PangoFontDescription *font_desc;
		gchar *fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(dialog));

		g_printf("%s\n", fontname);

		font_desc = pango_font_description_from_string(fontname);

		gtk_widget_modify_font(GTK_WIDGET(label), font_desc);

		g_free(fontname);
	}

	gtk_widget_destroy(dialog);
}
Beispiel #2
0
void
on_fontselectionbutton_clicked         (GtkButton       *button,
                                        gpointer         user_data)
{
    int whichbutton, whichfont;
    gchar *fontname;
    v5d_info *info;

    whichbutton = (int) user_data;

    printf("whichbutton = %d\n",whichbutton);

    if(whichbutton==0) { /* OK */
        fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG (FontSelectionDialog));

        whichfont = (int) gtk_object_get_data(GTK_OBJECT(FontSelectionDialog),"Font");
        info = (v5d_info *) gtk_object_get_data(GTK_OBJECT(FontSelectionDialog),"v5d_info");

        vis5d_set_font(info->v5d_display_context,fontname,0,whichfont);
    }

    gtk_widget_hide(FontSelectionDialog);

}
Beispiel #3
0
/*
* fontsel	: a GtkFontSelectionDialog.
* 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 typeClipStrVar_s_of_ClipVar.
* foundries 	: a NULL-terminated array of strings containing foundry names which
*		  will be shown, or NULL to show all foundrieClipStrVar_s_of_ClipVar.
* weights 	: a NULL-terminated array of strings containing weight names which
*		  will be shown, or NULL to show all weightClipStrVar_s_of_ClipVar.
* slants 		: a NULL-terminated array of strings containing slant names which will
*		  be shown, or NULL to show all slantClipStrVar_s_of_ClipVar.
* setwidths 	: a NULL-terminated array of strings containing setwidth names which
*		  will be shown, or NULL to show all setwidthClipStrVar_s_of_ClipVar.
* spacings 	: a NULL-terminated array of strings containing spacings which will be
*		  shown, or NULL to show all spacingClipStrVar_s_of_ClipVar.
* charsets 	: a NULL-terminated array of strings containing charset names which will
*		  be shown, or NULL to show all charsetClipStrVar_s_of_ClipVar.
*/
int
clip_GTK_FONTSELECTIONDIALOGSETFILTER(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_DIALOG);
   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_dialog_set_filter(GTK_FONT_SELECTION_DIALOG
					(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;
}
GtkWidget*
trackersettings_new (void)
{
    TrackerSettings *ts;
    gchar *clisttitles[] = { _("Font list") };
    GtkWidget *hbox1, *thing;

    ts = g_object_new(trackersettings_get_type(), NULL);
    GTK_BOX(ts)->spacing = 2;
    GTK_BOX(ts)->homogeneous = FALSE;

    ts->clist_selected_row = -1;
    ts->current_font = 0;

    ts->list = gui_stringlist_in_scrolled_window(1, clisttitles, GTK_WIDGET(ts));
    gui_list_handle_selection(ts->list, 
			      G_CALLBACK(trackersettings_clist_selected), ts);

    trackersettings_gui_populate_clist(ts);

    hbox1 = gtk_hbox_new(TRUE, 4);
    gtk_box_pack_start(GTK_BOX(ts), hbox1, FALSE, TRUE, 0);
    gtk_widget_show(hbox1);

    thing = ts->add_button = gtk_button_new_with_label(_("Add font"));
    gtk_box_pack_start(GTK_BOX(hbox1), thing, TRUE, TRUE, 0);
    gtk_widget_show(thing);
    g_signal_connect(thing, "clicked",
			G_CALLBACK(trackersettings_add_font), ts);

    thing = ts->delete_button = gtk_button_new_with_label(_("Delete font"));
    gtk_box_pack_start(GTK_BOX(hbox1), thing, TRUE, TRUE, 0);
    gtk_widget_show(thing);
    g_signal_connect(thing, "clicked",
			G_CALLBACK(trackersettings_delete_font), ts);

    thing = ts->apply_button = gtk_button_new_with_label(_("Apply font"));
    gtk_box_pack_start(GTK_BOX(hbox1), thing, TRUE, TRUE, 0);
    gtk_widget_show(thing);
    g_signal_connect(thing, "clicked",
			G_CALLBACK(trackersettings_apply_font), ts);

    hbox1 = gtk_hbox_new(TRUE, 4);
    gtk_box_pack_start(GTK_BOX(ts), hbox1, FALSE, TRUE, 0);
    gtk_widget_show(hbox1);

    ts->up_button = gui_button(GTK_WIDGET(ts), GTK_STOCK_GO_UP,
			       trackersettings_font_up, ts, hbox1);

    ts->down_button = gui_button(GTK_WIDGET(ts), GTK_STOCK_GO_DOWN,
				 trackersettings_font_down, ts, hbox1);

    ts->fontsel_dialog = gtk_font_selection_dialog_new(_("Select font..."));
    gtk_window_set_modal(GTK_WINDOW(ts->fontsel_dialog), TRUE);
    g_signal_connect(GTK_FONT_SELECTION_DIALOG(ts->fontsel_dialog)->ok_button, "clicked",
			G_CALLBACK(trackersettings_add_font_ok), ts);
    g_signal_connect(GTK_FONT_SELECTION_DIALOG(ts->fontsel_dialog)->cancel_button, "clicked",
			G_CALLBACK(trackersettings_add_font_cancel), ts);

    return GTK_WIDGET(ts);
}
Beispiel #5
0
static void
on_setup_fonts_button_clicked(GtkWidget *widget, COption *parent)
{
	GtkWidget *dlg;
	gint result;
	gchar *font_name;
	if (widget==parent->font_button1)
	{
		dlg = gtk_font_selection_dialog_new(_("Choose the normal english font"));
		gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (parent->window));
		gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(dlg),gtk_button_get_label(GTK_BUTTON(widget)));
		gtk_font_selection_dialog_set_preview_text(GTK_FONT_SELECTION_DIALOG(dlg),"Normal english font");
		result = gtk_dialog_run (GTK_DIALOG (dlg));
		switch (result)
		{
		case GTK_RESPONSE_OK:
			font_name = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(dlg));
			if (font_name)
			{
				gtk_button_set_label(GTK_BUTTON(widget),font_name);
				rw_cfg_write_string (usercfgfile, "reciteword", "normal_english_font", font_name);
			}
			break;
		default:
			break;
		}
		gtk_widget_destroy (dlg);
	}
	else if (widget==parent->font_button2)
	{
		dlg = gtk_font_selection_dialog_new(_("Choose the big english font"));
		gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (parent->window));
		gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(dlg),gtk_button_get_label(GTK_BUTTON(widget)));
		gtk_font_selection_dialog_set_preview_text(GTK_FONT_SELECTION_DIALOG(dlg),"Big english font");
		result = gtk_dialog_run (GTK_DIALOG (dlg));
		switch (result)
		{
		case GTK_RESPONSE_OK:
			font_name = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(dlg));
			if (font_name)
			{
				gtk_button_set_label(GTK_BUTTON(widget),font_name);
				rw_cfg_write_string (usercfgfile, "reciteword", "big_english_font", font_name);
			}
			break;
		default:
			break;
		}
		gtk_widget_destroy (dlg);
	}
	else if (widget==parent->font_button3)
	{
		dlg = gtk_font_selection_dialog_new(_("Choose the local language font"));
		gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (parent->window));
		gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(dlg),gtk_button_get_label(GTK_BUTTON(widget)));
		gtk_font_selection_dialog_set_preview_text(GTK_FONT_SELECTION_DIALOG(dlg),_("Local language font"));
		result = gtk_dialog_run (GTK_DIALOG (dlg));
		switch (result)
		{
		case GTK_RESPONSE_OK:
			font_name = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(dlg));
			if (font_name)
			{
				gtk_button_set_label(GTK_BUTTON(widget),font_name);
				rw_cfg_write_string (usercfgfile, "reciteword", "local_language_font", font_name);
			}
			break;
		default:
			break;
		}
		gtk_widget_destroy (dlg);
	}
}
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;
}
Beispiel #7
0
bool wxFontDialog::DoCreate(wxWindow *parent)
{
    m_needParent = FALSE;

    if (!PreCreation( parent, wxDefaultPosition, wxDefaultSize ) ||
            !CreateBase( parent, -1, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE,
                         wxDefaultValidator, wxT("fontdialog") ))
    {
        wxFAIL_MSG( wxT("wxFontDialog creation failed") );
        return FALSE;
    }

    wxString m_message( _("Choose font") );
    m_widget = gtk_font_selection_dialog_new( wxGTK_CONV( m_message ) );

    if (parent)
        gtk_window_set_transient_for(GTK_WINDOW(m_widget),
                                     GTK_WINDOW(parent->m_widget));

    GtkFontSelectionDialog *sel = GTK_FONT_SELECTION_DIALOG(m_widget);

    gtk_signal_connect( GTK_OBJECT(sel->ok_button), "clicked",
                        GTK_SIGNAL_FUNC(gtk_fontdialog_ok_callback), (gpointer*)this );

#ifndef __WXGTK20__
    // strange way to internationalize
    gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->ok_button) ), _("OK") );
#endif

    gtk_signal_connect( GTK_OBJECT(sel->cancel_button), "clicked",
                        GTK_SIGNAL_FUNC(gtk_fontdialog_cancel_callback), (gpointer*)this );

#ifndef __WXGTK20__
    // strange way to internationalize
    gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->cancel_button) ), _("Cancel") );
#endif

    gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
                        GTK_SIGNAL_FUNC(gtk_fontdialog_delete_callback), (gpointer)this );

    wxFont font = m_fontData.GetInitialFont();
    if( font.Ok() )
    {
        const wxNativeFontInfo *info = font.GetNativeFontInfo();

        if ( info )
        {

#ifdef __WXGTK20__
            const wxString& fontname = info->ToString();
#else
            const wxString& fontname = info->GetXFontName();
            if ( !fontname )
                font.GetInternalFont();
#endif
            gtk_font_selection_dialog_set_font_name(sel, wxGTK_CONV(fontname));
        }
        else
        {
            // this is not supposed to happen!
            wxFAIL_MSG(_T("font is ok but no native font info?"));
        }
    }

    return TRUE;
}