Esempio n. 1
0
static void ChooseFont (Widget_t p_wPB, void *p_pvPlugin)
{
    struct plugin_t *poPlugin = (plugin_t *) p_pvPlugin;
    struct param_t *poConf = &(poPlugin->oConf.oParam);
    Widget_t        wDialog;
    const char     *pcFont = poConf->acFont;
    int             iResponse;

    wDialog = gtk_font_selection_dialog_new (_("Font Selection"));
    gtk_window_set_transient_for (GTK_WINDOW (wDialog),
				  GTK_WINDOW (poPlugin->oConf.wTopLevel));
    if (*pcFont != '(')		/* Default font */
	gtk_font_selection_dialog_set_font_name (GTK_FONT_SELECTION_DIALOG
						 (wDialog), pcFont);
    iResponse = gtk_dialog_run (GTK_DIALOG (wDialog));
    if (iResponse == GTK_RESPONSE_OK) {
	pcFont = gtk_font_selection_dialog_get_font_name
	    (GTK_FONT_SELECTION_DIALOG (wDialog));
	if (pcFont && (strlen (pcFont) < sizeof (poConf->acFont) - 1)) {
	    strcpy (poConf->acFont, pcFont);
	    gtk_button_set_label (GTK_BUTTON (p_wPB), poConf->acFont);
	}
    }
    gtk_widget_destroy (wDialog);
}				/* ChooseFont() */
Esempio n. 2
0
static void
ti_font_select_cb (GtkWidget *widget, GUI *appGUI)
{
	GtkWidget *font_selector;
	gchar *font_name;
	gint response;

	font_selector = gtk_font_selection_dialog_new (_("Select a font..."));
	gtk_window_set_modal (GTK_WINDOW (font_selector), TRUE);
	gtk_window_set_position (GTK_WINDOW (font_selector), GTK_WIN_POS_MOUSE);
	gtk_window_set_transient_for (GTK_WINDOW (font_selector), GTK_WINDOW (appGUI->main_window));
	gtk_font_selection_dialog_set_font_name (GTK_FONT_SELECTION_DIALOG (font_selector), config.task_info_font);
	gtk_widget_show (font_selector);
	response = gtk_dialog_run (GTK_DIALOG (font_selector));

	if (response == GTK_RESPONSE_OK) {
		font_name = gtk_font_selection_dialog_get_font_name (GTK_FONT_SELECTION_DIALOG (font_selector));
		g_strlcpy (config.task_info_font, font_name, MAXFONTNAME);
		gtk_entry_set_text (GTK_ENTRY (appGUI->opt->ti_font_entry), font_name);
		g_free (font_name);
		g_object_set (G_OBJECT (appGUI->tsk->font_tag_object), "font", (gchar *) config.task_info_font, NULL);
	}

	gtk_widget_destroy (font_selector);
}
static void
datetime_font_selection_cb(GtkWidget *widget, gpointer data)
{
    DatetimePlugin *datetime;
    GtkWidget *dialog;
    gint result;

    g_return_if_fail (data != NULL);

    datetime = (DatetimePlugin*)data;

    dialog = gtk_font_selection_dialog_new("Select font");
    gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(dialog),
	   	 			    datetime->font);
    gtk_font_selection_dialog_set_preview_text(GTK_FONT_SELECTION_DIALOG(dialog),
				    gtk_label_get_text(GTK_LABEL(datetime->label)));
    result = gtk_dialog_run(GTK_DIALOG(dialog));
    if (result == GTK_RESPONSE_OK || result == GTK_RESPONSE_ACCEPT) {
	gchar *font_name;
	font_name = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(dialog));
	if (font_name != NULL)
	    gtk_button_set_label(GTK_BUTTON(widget), font_name);
    }
    gtk_widget_destroy(dialog);
}
Esempio n. 4
0
static void onTimerFontSelectClick(GtkWidget *widget, gpointer data)
{
	/* Unused parameters. */
	(void)widget;
	(void)data;

	GtkWidget *fontChooser = NULL;
	PangoFontDescription *font_desc = NULL;

	fontChooser = gtk_font_selection_dialog_new("Select Timer Font");
	gtk_font_selection_dialog_set_font_name(
			GTK_FONT_SELECTION_DIALOG(fontChooser), prefs.font_timer);

	if (gtk_dialog_run(GTK_DIALOG(fontChooser)) == GTK_RESPONSE_OK)
	{
		if (prefs.font_timer != NULL)
			g_free(prefs.font_timer);

		prefs.font_timer = gtk_font_selection_dialog_get_font_name(
				GTK_FONT_SELECTION_DIALOG(fontChooser));
		font_desc = pango_font_description_from_string(prefs.font_timer);
		gtk_widget_modify_font(timeElapsedLabel, font_desc);
		pango_font_description_free(font_desc);
	}

	gtk_widget_destroy(fontChooser);
}
Esempio n. 5
0
static void
modify_font (GtkWidget * data, gpointer value)
{
	GtkWidget *font_selector, *wait;
	gint response;
	gchar *selection = NULL;
	PangoFontDescription *pfd;

	font_selector = gtk_font_selection_dialog_new ("Select a font...");
	gtk_window_set_transient_for (GTK_WINDOW (font_selector),
				      GTK_WINDOW (value));
	gtk_font_selection_dialog_set_font_name (GTK_FONT_SELECTION_DIALOG
						 (font_selector),
						 grg_prefs_editor_font);
	gtk_widget_show (font_selector);
	response = gtk_dialog_run (GTK_DIALOG (font_selector));
	if (response == GTK_RESPONSE_OK)
	{
		pfd = pango_font_description_from_string
			(gtk_font_selection_dialog_get_font_name
			 (GTK_FONT_SELECTION_DIALOG (font_selector)));
		gtk_widget_modify_font (gtk_bin_get_child
					(GTK_BIN (but_font)), pfd);
		pango_font_description_free (pfd);
	}

	gtk_widget_destroy (font_selector);
}
Esempio n. 6
0
static void
purplerc_set_font(GtkWidget *widget, gpointer data)
{
	gchar title[128];
	GtkWidget *font_dialog = NULL;
	gint subscript = GPOINTER_TO_INT(data);
	const gchar *pref = NULL, *prefpath = NULL;

	if (subscript == -1) {
		g_snprintf(title, sizeof(title), _("Select Interface Font"));
		prefpath = "/plugins/gtk/purplerc/gtk-font-name";
	} else {
		g_snprintf(title, sizeof(title), _("Select Font for %s"),
		           _(font_names[subscript]));
		prefpath = font_prefs[subscript];
	}

	font_dialog = gtk_font_selection_dialog_new(title);
	g_signal_connect(G_OBJECT(font_dialog), "response",
	                 G_CALLBACK(purplerc_font_response), data);

	pref = purple_prefs_get_string(prefpath);

	if (pref != NULL && strcmp(pref, "")) {
		gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(font_dialog), pref);
	}

	gtk_window_present(GTK_WINDOW(font_dialog));
}
Esempio n. 7
0
static void
run_fontsel_settings_dlg(SettingsWidget *sw) {
    GtkWidget *dlg;
    const gchar *newfont;
    gchar *oldfont;

    dlg = gtk_font_selection_dialog_new(_("Select font"));
    gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(dlg),
                                            gtk_label_get_text(GTK_LABEL(sw->widget)));

    if (gtk_dialog_run(GTK_DIALOG(dlg)) == GTK_RESPONSE_OK) {
        gtk_label_set_text(GTK_LABEL(sw->widget),
                           gtk_font_selection_dialog_get_font_name(
                               GTK_FONT_SELECTION_DIALOG(dlg)));
    }


    newfont = gtk_label_get_text(GTK_LABEL(sw->widget));
    oldfont = pango_font_description_to_string(
                  pango_context_get_font_description(
                      gtk_widget_get_pango_context(GTK_WIDGET(sw->data))));

    if (newfont && g_ascii_strcasecmp(oldfont, newfont) != 0) {
        string_replace(sw->conf, g_strdup(newfont));
        jam_widget_set_font(sw->widget, newfont);
        jam_widget_set_font(sw->data, newfont);
    }
    g_free(oldfont);

    gtk_widget_destroy(dlg);
}
Esempio n. 8
0
/**
 * gtk_font_button_set_font_name:
 * @font_button: a #GtkFontButton
 * @fontname: Name of font to display in font selection dialog
 *
 * Sets or updates the currently-displayed font in font picker dialog.
 *
 * Returns: Return value of gtk_font_selection_dialog_set_font_name() if the
 * font selection dialog exists, otherwise %FALSE.
 *
 * Since: 2.4
 */
gboolean 
gtk_font_button_set_font_name (GtkFontButton *font_button,
                               const gchar    *fontname)
{
  gboolean result;
  gchar *old_fontname;

  g_return_val_if_fail (GTK_IS_FONT_BUTTON (font_button), FALSE);
  g_return_val_if_fail (fontname != NULL, FALSE);
  
  if (g_ascii_strcasecmp (font_button->priv->fontname, fontname)) 
    {
      old_fontname = font_button->priv->fontname;
      font_button->priv->fontname = g_strdup (fontname);
      g_free (old_fontname);
    }
  
  gtk_font_button_update_font_info (font_button);
  
  if (font_button->priv->font_dialog)
    result = gtk_font_selection_dialog_set_font_name (GTK_FONT_SELECTION_DIALOG (font_button->priv->font_dialog), 
                                                      font_button->priv->fontname);
  else
    result = FALSE;

  g_object_notify (G_OBJECT (font_button), "font-name");

  return result;
}
Esempio n. 9
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 );

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

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

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

    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.IsOk() )
    {
        const wxNativeFontInfo *info = font.GetNativeFontInfo();

        if ( info )
        {

            const wxString& fontname = info->GetXFontName();
            if ( !fontname )
                font.GetInternalFont();

            gtk_font_selection_dialog_set_font_name(sel, wxGTK_CONV(fontname));
        }
        else
        {
            // this is not supposed to happen!
            wxFAIL_MSG(wxT("font is ok but no native font info?"));
        }
    }

    return true;
}
Esempio n. 10
0
G_MODULE_EXPORT void
action_font_activate_cb(GtkWidget *widget, EDITOR *e)
{
	GtkWidget *dialog;
	gchar *selected_text = NULL;
	gchar *size = NULL;
#ifdef HAVE_GTK_32
	dialog = gtk_font_chooser_dialog_new("Select font", NULL);
	gtk_font_chooser_set_font((GtkFontChooser *)dialog,
#else
	dialog = gtk_font_selection_dialog_new("Select font");
	gtk_font_selection_dialog_set_font_name((GtkFontSelectionDialog *)
						dialog,
#endif
				  "Droid Sans 14");

	if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
#ifdef HAVE_GTK_32
		const gchar *fontname = gtk_font_chooser_get_font((GtkFontChooser *)dialog);
#else
		const gchar *fontname = gtk_font_selection_dialog_get_font_name((GtkFontSelectionDialog *)dialog);
#endif
		GString *name = g_string_new(fontname);
		size = get_font_size_from_name(name);
		g_string_free(name, TRUE);

		selected_text = editor_get_selected_text(e);
#ifdef HAVE_GTK_32
		PangoFontDescription *font_description =
			gtk_font_chooser_get_font_desc((GtkFontChooser *)
						       dialog);
		fontname = pango_font_description_get_family(font_description);
#else
		PangoFontDescription *font_description =
			pango_font_description_from_string(fontname);
		fontname = pango_font_description_get_family(font_description);
#endif

		gchar *script = g_strdup_printf("<SPAN STYLE=\"font-family:%s;font-size:%spx;\">%s</SPAN>",
						fontname, size, selected_text);

		editor_insert_html(script, e);
		g_free(script);
	}
	if (size)
		g_free(size);
	if (selected_text)
		g_free(selected_text);
	gtk_widget_destroy(dialog);
}
Esempio n. 11
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);

    g_signal_connect (sel->ok_button, "clicked",
                      G_CALLBACK (gtk_fontdialog_ok_callback), this);

    g_signal_connect (sel->cancel_button, "clicked",
                      G_CALLBACK (gtk_fontdialog_cancel_callback), this);

    g_signal_connect (m_widget, "delete_event",
                      G_CALLBACK (gtk_fontdialog_delete_callback), this);

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

        if ( info )
        {

            const wxString& fontname = info->ToString();
            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;
}
Esempio n. 12
0
static gchar *get_font_name_by_selector(GtkWidget *window, gchar *current_fontname)
{
	GtkWidget *dialog;
	gchar *fontname;
	
	dialog = gtk_font_selection_dialog_new(_("Font"));
	gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(window));
	gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(dialog), current_fontname);
	if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
		fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(dialog));
	else
		fontname = NULL;
	gtk_widget_destroy(dialog);
		
	return fontname;
}
Esempio n. 13
0
/* Sets the currently-selected font. */
int
clip_GTK_FONTSELECTIONDIALOGSETFONTNAME(ClipMachine * ClipMachineMemory)
{
   C_widget *cfsel = _fetch_cw_arg(ClipMachineMemory);

   gchar    *font_name = _clip_parc(ClipMachineMemory, 2);

   CHECKCWID(cfsel, GTK_IS_FONT_SELECTION_DIALOG);
   CHECKOPT(2, CHARACTER_type_of_ClipVarType);
   if (_clip_parinfo(ClipMachineMemory, 2) == UNDEF_type_of_ClipVarType)
      font_name = "\0";
   _clip_retl(ClipMachineMemory, gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(cfsel->widget), font_name));
   return 0;
 err:
   return 1;
}
Esempio n. 14
0
//フォントを設定する
void set_font(void)
{
    GtkWidget *font_dialog = gtk_font_selection_dialog_new("フォント");
    gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(font_dialog), font_name);
    gtk_font_selection_dialog_set_preview_text(GTK_FONT_SELECTION_DIALOG(font_dialog), "abcdefghij ABCDEFGHIJ あいうえお");
    gtk_dialog_set_default_response(GTK_DIALOG(font_dialog), GTK_RESPONSE_OK);
    
    if (gtk_dialog_run(GTK_DIALOG(font_dialog)) == GTK_RESPONSE_OK) {
        char *name = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(font_dialog));
        strcpy(font_name, name);
        gtk_widget_modify_font(view, pango_font_description_from_string(name));
        free(name);
    }
    
    gtk_widget_destroy(font_dialog);
}
Esempio n. 15
0
void
utl_gui_font_select_cb (GtkWidget *widget, gpointer user_data)
{
	GtkWidget *font_selector;
	gchar *font_name;
	gint response;

	FONT_SEL *sel = (FONT_SEL *) user_data;

	g_return_if_fail (sel->config != NULL);

	font_selector = gtk_font_selection_dialog_new (_("Select a font..."));
	gtk_window_set_modal (GTK_WINDOW (font_selector), TRUE);
	gtk_window_set_position (GTK_WINDOW (font_selector), GTK_WIN_POS_MOUSE);
	gtk_window_set_transient_for (GTK_WINDOW (font_selector), GTK_WINDOW (sel->appGUI->main_window));
	gtk_font_selection_dialog_set_font_name (GTK_FONT_SELECTION_DIALOG (font_selector),
	                                         sel->config);
	gtk_widget_show (font_selector);

	response = gtk_dialog_run (GTK_DIALOG (font_selector));

	if (response == GTK_RESPONSE_OK) {

		font_name = gtk_font_selection_dialog_get_font_name (GTK_FONT_SELECTION_DIALOG (font_selector));

		if (sel->save == TRUE)
			g_strlcpy (sel->config, font_name, MAXFONTNAME);

		if (sel->entry != NULL)
			gtk_entry_set_text (GTK_ENTRY (sel->entry), font_name);

		if (sel->font != NULL) {

			pango_font_description_free (*sel->font);
			*sel->font = pango_font_description_from_string (font_name);

			if (sel->widget != NULL)
				gtk_widget_modify_font (GTK_WIDGET (sel->widget), *sel->font);

		}

		g_free (font_name);

	}

	gtk_widget_destroy (font_selector);
}
Esempio n. 16
0
/*
 * Create dialog window for font selection.
 */
int
font_dialog_window(GtkButton * button, gpointer user_data)
{
  GtkWidget *font_dialog;
  GtkWidget *vbox;
  GtkWidget *cancel_button, *apply_button, *ok_button;
  GList *children;

  DEBUG("font_dialog_window");
  font_dialog = gtk_font_selection_dialog_new("XOSD Font");

  assert(font_dialog);

  if (font)
    gtk_font_selection_dialog_set_font_name
      (GTK_FONT_SELECTION_DIALOG(font_dialog), font);

  children = gtk_container_children(GTK_CONTAINER(font_dialog));

  vbox = GTK_WIDGET(children->data);

  children = gtk_container_children(GTK_CONTAINER(vbox));

  vbox = GTK_WIDGET(children->next->data);
  children = gtk_container_children(GTK_CONTAINER(vbox));
  ok_button = GTK_WIDGET(children->data);

  apply_button = GTK_WIDGET(children->next->data);

  cancel_button = GTK_WIDGET(children->next->next->data);

  gtk_signal_connect_object(GTK_OBJECT(cancel_button), "clicked",
                            GTK_SIGNAL_FUNC(gtk_widget_destroy),
                            GTK_OBJECT(font_dialog));

  gtk_signal_connect(GTK_OBJECT(ok_button), "clicked",
                     GTK_SIGNAL_FUNC(font_dialog_ok), font_dialog);
  gtk_signal_connect(GTK_OBJECT(apply_button), "clicked",
                     GTK_SIGNAL_FUNC(font_dialog_apply), font_dialog);


  gtk_widget_show_all(font_dialog);
  return 0;
}
Esempio n. 17
0
static void
gtk_font_button_clicked (GtkButton *button)
{
  GtkFontSelectionDialog *font_dialog;
  GtkFontButton    *font_button = GTK_FONT_BUTTON (button);
  
  if (!font_button->priv->font_dialog) 
    {
      GtkWidget *parent;
      
      parent = gtk_widget_get_toplevel (GTK_WIDGET (font_button));
      
      font_button->priv->font_dialog = gtk_font_selection_dialog_new (font_button->priv->title);
      
      font_dialog = GTK_FONT_SELECTION_DIALOG (font_button->priv->font_dialog);
      
      if (GTK_WIDGET_TOPLEVEL (parent) && GTK_IS_WINDOW (parent))
        {
          if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (font_dialog)))
 	    gtk_window_set_transient_for (GTK_WINDOW (font_dialog), GTK_WINDOW (parent));
	       
	  gtk_window_set_modal (GTK_WINDOW (font_dialog),
				gtk_window_get_modal (GTK_WINDOW (parent)));
	}

      g_signal_connect (font_dialog->ok_button, "clicked",
                        G_CALLBACK (dialog_ok_clicked), font_button);
      g_signal_connect (font_dialog->cancel_button, "clicked",
			G_CALLBACK (dialog_cancel_clicked), font_button);
      g_signal_connect (font_dialog, "destroy",
                        G_CALLBACK (dialog_destroy), font_button);
    }
  
  if (!GTK_WIDGET_VISIBLE (font_button->priv->font_dialog)) 
    {
      font_dialog = GTK_FONT_SELECTION_DIALOG (font_button->priv->font_dialog);
      
      gtk_font_selection_dialog_set_font_name (font_dialog, font_button->priv->fontname);
      
    } 

  gtk_window_present (GTK_WINDOW (font_button->priv->font_dialog));
}
Esempio n. 18
0
static void
font_click(GtkButton * button, gpointer user_data)
{
	GtkWidget *dlg;
	gchar *fn = NULL;
	gint resp;
	fn = (gchar *) gtk_entry_get_text(GTK_ENTRY(user_data));
	dlg = gtk_font_selection_dialog_new(_("Select Font"));
	if (fn && *fn)
	{
		gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(dlg), fn);
	}
	resp = gtk_dialog_run(GTK_DIALOG(dlg));
	if (resp == GTK_RESPONSE_OK)
	{
		fn = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(dlg));
		if (fn)
		{
			gtk_entry_set_text(GTK_ENTRY(user_data), fn);
			g_free(fn);
		}
	}
	gtk_widget_destroy(dlg);
}
Esempio n. 19
0
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;
}
Esempio n. 20
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);
	}
}
Esempio n. 21
0
static int gtkFontDlgPopup(Ihandle* ih, int x, int y)
{
  InativeHandle* parent = iupDialogGetNativeParent(ih);
  GtkFontSelectionDialog* dialog;
  int response;
  char* preview_text, *standardfont;

  iupAttribSetInt(ih, "_IUPDLG_X", x);   /* used in iupDialogUpdatePosition */
  iupAttribSetInt(ih, "_IUPDLG_Y", y);

  dialog = (GtkFontSelectionDialog*)gtk_font_selection_dialog_new(iupgtkStrConvertToUTF8(iupAttribGet(ih, "TITLE")));
  if (!dialog)
    return IUP_ERROR;

  if (parent)
    gtk_window_set_transient_for((GtkWindow*)dialog, (GtkWindow*)parent);

  standardfont = iupAttribGet(ih, "VALUE");
  if (!standardfont)
    standardfont = IupGetGlobal("DEFAULTFONT");
  gtk_font_selection_dialog_set_font_name(dialog, standardfont);

  preview_text = iupAttribGet(ih, "PREVIEWTEXT");
  if (preview_text)
    gtk_font_selection_dialog_set_preview_text(dialog, preview_text);

  if (IupGetCallback(ih, "HELP_CB"))
    gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_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)
  {
    char* fontname = gtk_font_selection_dialog_get_font_name(dialog);
    iupAttribStoreStr(ih, "VALUE", fontname);
    g_free(fontname);
    iupAttribSetStr(ih, "STATUS", "1");
  }
  else
  {
    iupAttribSetStr(ih, "VALUE", NULL);
    iupAttribSetStr(ih, "STATUS", NULL);
  }

  gtk_widget_destroy(GTK_WIDGET(dialog));  

  return IUP_NOERROR;
}