コード例 #1
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);
}
コード例 #2
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() */
コード例 #3
0
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);
}
コード例 #4
0
ファイル: pidginrc.c プロジェクト: Draghtnod/pidgin
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));
}
コード例 #5
0
ファイル: calendar.c プロジェクト: omork/mythryl
void calendar_select_font( GtkWidget    *button,
                           CalendarData *calendar )
{
  GtkWidget *window;

  if (!calendar->font_dialog) {
    window = gtk_font_selection_dialog_new ("Font Selection Dialog");
    g_return_if_fail(GTK_IS_FONT_SELECTION_DIALOG(window));
    calendar->font_dialog = window;
    
    gtk_window_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE);
    
    gtk_signal_connect (GTK_OBJECT (window), "destroy",
			GTK_SIGNAL_FUNC (gtk_widget_destroyed),
			&calendar->font_dialog);
    
    gtk_signal_connect (GTK_OBJECT (GTK_FONT_SELECTION_DIALOG (window)->ok_button),
			"clicked", GTK_SIGNAL_FUNC(calendar_font_selection_ok),
			calendar);
    gtk_signal_connect_object (GTK_OBJECT (GTK_FONT_SELECTION_DIALOG (window)->cancel_button),
			       "clicked",
			       GTK_SIGNAL_FUNC (gtk_widget_destroy), 
			       GTK_OBJECT (calendar->font_dialog));
  }
  window=calendar->font_dialog;
  if (!gtk_widget_visible (window))
    gtk_widget_show (window);
  else
    gtk_widget_destroy (window);

}
コード例 #6
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));

    font_desc = pango_font_description_from_string(fontname);

    gtk_widget_modify_font(GTK_WIDGET(label), font_desc);

    g_free(fontname);
   }


  gtk_widget_destroy(dialog);
}
コード例 #7
0
ファイル: settings.c プロジェクト: nightmorph/LogJam
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);
}
コード例 #8
0
ファイル: tasks_preferences_gui.c プロジェクト: rosedu/osmo
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);
}
コード例 #9
0
ファイル: pdfpres.c プロジェクト: betagram/pdfPres
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);
}
コード例 #10
0
ファイル: fontdlg.cpp プロジェクト: CobaltBlues/wxWidgets
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;
}
コード例 #11
0
ファイル: webkit_editor.c プロジェクト: elijahdorman/Xiphos
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);
}
コード例 #12
0
ファイル: fontdlg.cpp プロジェクト: SCP-682/Cities3D
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;
}
コード例 #13
0
ファイル: font.c プロジェクト: Aseeker/leafpad
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;
}
コード例 #14
0
ファイル: menu_option.c プロジェクト: kawatea/cedit
//フォントを設定する
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);
}
コード例 #15
0
ファイル: utils_gui.c プロジェクト: rosedu/osmo
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);
}
コード例 #16
0
ファイル: dlg_font.c プロジェクト: powertomato/ScreenInvader
/*
 * 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;
}
コード例 #17
0
ファイル: gtkfontbutton.c プロジェクト: batman52/dingux-code
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));
}
コード例 #18
0
ファイル: gui_dialogs.c プロジェクト: krzyzanowskim/GNUGadu
/* 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);
}
コード例 #19
0
ファイル: fontsel.c プロジェクト: amery/clip-angelo
/****  Font selection dialog constructor ****/
int
clip_GTK_FONTSELECTIONDIALOGNEW(ClipMachine * ClipMachineMemory)
{
   ClipVar  *cv = _clip_spar(ClipMachineMemory, 1);

   char     *title = _clip_parc(ClipMachineMemory, 2);

   GtkWidget *wid = NULL;

   C_widget *cwid, *cokbtn, *capplybtn, *ccancelbtn;

   CHECKOPT(1, MAP_type_of_ClipVarType);
   CHECKOPT(2, CHARACTER_type_of_ClipVarType);

   if (_clip_parinfo(ClipMachineMemory, 2) == UNDEF_type_of_ClipVarType)
      title = "\0";
   LOCALE_TO_UTF(title);
   wid = gtk_font_selection_dialog_new(title);
   FREE_TEXT(title);
   cwid = _register_widget(ClipMachineMemory, wid, cv);
   cokbtn = _register_widget(ClipMachineMemory, GTK_FONT_SELECTION_DIALOG(wid)->ok_button, NULL);
   capplybtn = _register_widget(ClipMachineMemory, GTK_FONT_SELECTION_DIALOG(wid)->apply_button, NULL);
   ccancelbtn = _register_widget(ClipMachineMemory, GTK_FONT_SELECTION_DIALOG(wid)->cancel_button, NULL);

   if (cokbtn)
      _clip_madd(ClipMachineMemory, &cwid->obj, HASH_OKBUTTON, &cokbtn->obj);
   if (capplybtn)
      _clip_madd(ClipMachineMemory, &cwid->obj, HASH_APPLYBUTTON, &capplybtn->obj);
   if (ccancelbtn)
      _clip_madd(ClipMachineMemory, &cwid->obj, HASH_CANCELBUTTON, &ccancelbtn->obj);

   _clip_mclone(ClipMachineMemory, RETPTR(ClipMachineMemory), &cwid->obj);
   return 0;
 err:
   return 1;
}
コード例 #20
0
ファイル: gdb-ui-envir.c プロジェクト: Enrix835/geany-plugins
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);
}
コード例 #21
0
ファイル: xwt_gtk_fontselect.c プロジェクト: xharbour/core
BOOL xwt_gtk_createFontSelection( PXWT_WIDGET xwtData )
{
   GtkWidget *filew;
   PXWT_GTK_MODAL xwtFilew;

   xwtFilew = (PXWT_GTK_MODAL) hb_xgrab( sizeof( XWT_GTK_MODAL ) );

   filew = gtk_font_selection_dialog_new("");
   // this widget is NOT displayed by default
   xwtFilew->a.main_widget = filew;
   xwtFilew->modal = FALSE;
   xwtFilew->canceled = FALSE;

   // we need both the owner of the widget, and the widget itself;
   // so it is useful to pass the xwt_gtk data.
   g_signal_connect (
      G_OBJECT (GTK_FONT_SELECTION_DIALOG (filew)->ok_button),
      "clicked", G_CALLBACK (font_ok_sel), xwtData
   );

   g_signal_connect(
      G_OBJECT (GTK_FONT_SELECTION_DIALOG (filew)->cancel_button),
      "clicked", G_CALLBACK (font_cancel_sel),xwtData);

   // you ALWAYS need to set the xwtData->widget_data.
   // if no driver level widget wrapper is needed, you can
   // use the gtkWidget here, and set NULL for the destructor.
   xwtData->widget_data = xwtFilew;
   // xwtData->widget_data is just allocated with hb_xgrab;
   // an xfree will be enough to get rid of it.
   xwtData->destructor = hb_xfree;
   xwtData->get_main_widget = xwt_gtk_get_mainwidget_base;
   xwtData->get_top_widget = xwt_gtk_get_mainwidget_base;

   return TRUE;
}
コード例 #22
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;
}
コード例 #23
0
	gtk_adjustment_set_value(adj, MIN(value, real_upper));

	return TRUE;
}

static void
choose_font_activated(GtkWidget *widget __attribute__((unused)),
		      gpointer data)
{
	GtkExperimentTranscript *trans = GTK_EXPERIMENT_TRANSCRIPT(data);

	GtkWidget *dialog;
	gchar *font_name;

	dialog = gtk_font_selection_dialog_new("Choose Font...");

	font_name = pango_font_description_to_string(GTK_WIDGET(trans)->style->font_desc);
	gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(dialog),
						font_name);
	g_free(font_name);

	if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
		PangoFontDescription *font_desc;

		font_name = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(dialog));
		font_desc = pango_font_description_from_string(font_name);

		gtk_widget_modify_font(GTK_WIDGET(trans), font_desc);

		pango_font_description_free(font_desc);
コード例 #24
0
ファイル: option.cpp プロジェクト: tamsuiboy/reciteword-osx
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);
	}
}
コード例 #25
0
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);
}
コード例 #26
0
ファイル: iupgtk_fontdlg.c プロジェクト: Airr/iup_mac
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;
}