This is a small file to test the font combo.
Sorry, i forgot.
- Rob
On 6/9/05, Robert Staudinger <[EMAIL PROTECTED]> wrote:
> Hi,
>
> This is the, well, "patch" to goffice that adds a font combobox (as
> prototyped in AbiWord).
> What does it do:
> + On first startup it shows a combobox containing all system font
> families (showed in standard application font)
> + Using a timeout every second a font is "thumbnailed". The
> corresponding entry in the combo is rendered in its own font face
> using the thumbnail.
> + When all fonts are thumbnailed a cache file containing the
> thumbnails is written to .goffice.
> + Subsequent launches load the thumbnails from the cache file directly
> and don't have to touch the fonts at all.
> + If the system font size is changed new thumbnails are generated at
> next startup, same if new fonts are installed on the system.
>
> While not totally ready i'd like to get your feedback on this because
> its "structually complete" and does what it should.
> Unfortunately the crappy gnome anoncvs doesn't let me diff today so i
> hope it is ok to send the tarball with the files. They go in
> goffice/gtk.
>
> Outstanding polish:
> + Create a cell renderer that draws the text in theme color (currently
> black). Thumbnails have alpha channel, so background adapts to theme
> already.
> + Hook "style-changed" and redo thumbnails if fontsize has changed.
>
> Cheers,
> - Rob
>
>
>
#include <stdio.h>
#include <gtk/gtk.h>
#include <goffice/gtk/go-combo-font.h>
void
changed_cb (GtkComboBox *widget,
gpointer data)
{
GtkTreeModel *model = NULL;
GtkTreeIter iter;
gchar *family = NULL;
model = gtk_combo_box_get_model (widget);
if (gtk_combo_box_get_active_iter (widget, &iter)) {
gtk_tree_model_get (model, &iter, 0, &family, -1);
printf ("changed - '%s'\n", family);
}
else {
printf ("changed - empty\n");
}
}
void
clicked_cb (GtkButton *widget,
gpointer data)
{
GtkComboBox *combo = GTK_COMBO_BOX (data);
gtk_combo_box_set_active (combo, 5);
}
void
clicked2_cb (GtkButton *widget,
gpointer data)
{
GObject *combo = G_OBJECT (data);
GValue val = {0,};
g_value_init (&val, G_TYPE_STRING);
g_value_set_string (&val, "Arial");
g_object_set_property (combo, "font-family", &val);
}
void
clicked3_cb (GtkButton *widget,
gpointer data)
{
GObject *combo = G_OBJECT (data);
GValue val = {0,};
PangoFontDescription *desc;
desc = pango_font_description_new ();
pango_font_description_set_family (desc, "Verdana");
g_value_init (&val, G_TYPE_POINTER);
g_value_set_pointer (&val, desc);
g_object_set_property (combo, "font-description", &val);
}
void
clicked4_cb (GtkButton *widget,
gpointer data)
{
GObject *combo = G_OBJECT (data);
GValue val = {0,};
g_value_init (&val, G_TYPE_STRING);
g_object_get_property (combo, "font-family", &val);
printf ("font-family: '%s'\n", g_value_get_string (&val));
}
void
clicked5_cb (GtkButton *widget,
gpointer data)
{
GObject *combo = G_OBJECT (data);
GValue val = {0,};
g_value_init (&val, G_TYPE_POINTER);
g_object_get_property (combo, "font-description", &val);
printf ("font-description: '%s'\n", pango_font_description_get_family (g_value_get_pointer (&val)));
}
void
clicked6_cb (GtkButton *widget,
gpointer data)
{
GOComboFont *combo = GO_COMBO_FONT (data);
gchar *family = "Arial";
go_combo_font_set_family (combo, family);
}
void
clicked7_cb (GtkButton *widget,
gpointer data)
{
GOComboFont *combo = GO_COMBO_FONT (data);
PangoFontDescription *desc;
desc = pango_font_description_new ();
pango_font_description_set_family (desc, "Verdana");
go_combo_font_set_description (combo, desc);
}
void
clicked8_cb (GtkButton *widget,
gpointer data)
{
GOComboFont *combo = GO_COMBO_FONT (data);
printf ("font-family: '%s'\n", go_combo_font_get_family (combo));
}
void
clicked9_cb (GtkButton *widget,
gpointer data)
{
GOComboFont *combo = GO_COMBO_FONT (data);
printf ("font-description: '%s'\n", pango_font_description_get_family (go_combo_font_get_description (combo)));
}
int
main (int argc, char *argv[])
{
GtkWidget *dlg;
GtkWidget *box;
GtkWidget *combo;
GtkWidget *button;
gtk_init (&argc, &argv);
dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (dlg, "delete-event", gtk_main_quit, NULL);
box = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (dlg), box);
combo = go_combo_font_new ();
g_signal_connect (combo, "changed", G_CALLBACK (changed_cb), NULL);
gtk_box_pack_start (GTK_BOX (box), combo, TRUE, FALSE, 0);
button = gtk_button_new_with_label ("Set Font #5");
g_signal_connect (button, "clicked", G_CALLBACK (clicked_cb), combo);
gtk_box_pack_start (GTK_BOX (box), button, TRUE, FALSE, 0);
button = gtk_button_new_with_label ("Set family 'Arial'");
g_signal_connect (button, "clicked", G_CALLBACK (clicked2_cb), combo);
gtk_box_pack_start (GTK_BOX (box), button, TRUE, FALSE, 0);
button = gtk_button_new_with_label ("Set description 'Verdana'");
g_signal_connect (button, "clicked", G_CALLBACK (clicked3_cb), combo);
gtk_box_pack_start (GTK_BOX (box), button, TRUE, FALSE, 0);
button = gtk_button_new_with_label ("Get family");
g_signal_connect (button, "clicked", G_CALLBACK (clicked4_cb), combo);
gtk_box_pack_start (GTK_BOX (box), button, TRUE, FALSE, 0);
button = gtk_button_new_with_label ("Get description");
g_signal_connect (button, "clicked", G_CALLBACK (clicked5_cb), combo);
gtk_box_pack_start (GTK_BOX (box), button, TRUE, FALSE, 0);
button = gtk_button_new_with_label ("Set family 'Arial' (wrapper)");
g_signal_connect (button, "clicked", G_CALLBACK (clicked6_cb), combo);
gtk_box_pack_start (GTK_BOX (box), button, TRUE, FALSE, 0);
button = gtk_button_new_with_label ("Set description 'Verdana' (wrapper)");
g_signal_connect (button, "clicked", G_CALLBACK (clicked7_cb), combo);
gtk_box_pack_start (GTK_BOX (box), button, TRUE, FALSE, 0);
button = gtk_button_new_with_label ("Get family (wrapper)");
g_signal_connect (button, "clicked", G_CALLBACK (clicked8_cb), combo);
gtk_box_pack_start (GTK_BOX (box), button, TRUE, FALSE, 0);
button = gtk_button_new_with_label ("Get description (wrapper)");
g_signal_connect (button, "clicked", G_CALLBACK (clicked9_cb), combo);
gtk_box_pack_start (GTK_BOX (box), button, TRUE, FALSE, 0);
gtk_widget_show_all (dlg);
gtk_main ();
return 0;
}
_______________________________________________
gnumeric-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gnumeric-list