Web lists-archives.com

Re: Font selection panel




Hi,

On Thu, Dec 22, 2016 at 3:59 PM,  <cecashon@xxxxxxx> wrote:
>
> You should be able to put something together with a notebook widget
> wizardlike. Of course I have been caught with the "should be able to" before
> and spent hours working on what I shouldn't do in the first place. This
> looks to be do_able().
>
> Test it out. See if it helps. Happy Holidays.

Is there a way to set the initial font?
Also is there a way to have something like this on GTK+3?


And thank you for an example.

>
> Eric
>
>
> /*
>     gcc -Wall notebook1.c -o notebook1 `pkg-config --cflags --libs gtk+-3.0`
>     Tested on Ubuntu16.04 and GTK3.18
> */
>
> #include<gtk/gtk.h>
>
> static void click_button1(GtkWidget *widget, gpointer user_data)
>  {
>    g_print("Properties OK\n");
>  }
> static void click_button2(GtkWidget *widget, gpointer user_data)
>  {
>    gchar *selection=gtk_font_chooser_get_font(GTK_FONT_CHOOSER(user_data));
>    g_print("%s\n", selection);
>    g_free(selection);
>  }
> int main(int argc, char **argv)
>  {
>    gtk_init(&argc, &argv);
>
>    GtkWidget *window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
>    gtk_window_set_title(GTK_WINDOW(window), "Notebook Test");
>    gtk_window_set_default_size(GTK_WINDOW(window), 400, 400);
>    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
>    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
>
>    GtkWidget *label1=gtk_label_new("Some Properties");
>    gtk_widget_set_hexpand(label1, TRUE);
>    gtk_widget_set_vexpand(label1, TRUE);
>
>    GtkWidget *button1=gtk_button_new_with_label("Properties OK");
>    g_signal_connect(button1, "clicked", G_CALLBACK(click_button1), NULL);
>
>    GtkWidget *grid1=gtk_grid_new();
>    gtk_grid_attach(GTK_GRID(grid1), label1, 0, 0, 1, 1);
>    gtk_grid_attach(GTK_GRID(grid1), button1, 0, 1, 1, 1);
>
>    GtkWidget *font=gtk_font_chooser_widget_new();
>    gtk_widget_set_hexpand(font, TRUE);
>    gtk_widget_set_vexpand(font, TRUE);
>
>    GtkWidget *button2=gtk_button_new_with_label("Font OK");
>    g_signal_connect(button2, "clicked", G_CALLBACK(click_button2), font);
>
>    GtkWidget *grid2=gtk_grid_new();
>    gtk_grid_attach(GTK_GRID(grid2), font, 0, 0, 1, 1);
>    gtk_grid_attach(GTK_GRID(grid2), button2, 0, 1, 1, 1);
>
>    GtkWidget *notebook=gtk_notebook_new();
>    GtkWidget *notebook_label1=gtk_label_new("Properties");
>    GtkWidget *notebook_label2=gtk_label_new("Fonts");
>    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), grid1, notebook_label1);
>    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), grid2, notebook_label2);
>
>    gtk_container_add(GTK_CONTAINER(window), notebook);
>
>    gtk_widget_show_all(window);
>
>    gtk_main();
>    return 0;
>  }
>
>
>
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list