Re: Font selection panel



Thank you.
I will check it most likely after the holidays and report back.

Happy Holidays!!

On Fri, Dec 23, 2016 at 2:23 PM,  <cecashon aol com> wrote:

Give it a try. For GTK2 you can change a few things around to get it to
work.

Pass the selection or chooser with your apply button "clicked" signal and
you can apply the changes.

I tried the following with Ubuntu 16.04 and GTK2.24.30 and it worked. Maybe
get a start at setting something up. I would recommend GTK3 over GTK2 but if
GTK2 is the needed library then program with it.

I don't see a deprecated warning for gtk_font_selection_set_font_name() when
I compile in GTK2.


/*
    gcc -Wall notebook2.c -o notebook2 `pkg-config --cflags --libs gtk+-2.0`
*/

#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_selection_get_font_name(GTK_FONT_SELECTION(user_data));
   g_print("%s\n", selection);
   g_free(selection);
 }
static void set_font(GtkWidget *widget, gpointer user_data)
 {
   gtk_font_selection_set_font_name(GTK_FONT_SELECTION(widget), "Monospace
Bold 18");
 }
int main(int argc, char **argv)
 {
   gtk_init(&argc, &argv);
   g_print("%d.%d.%d\n", gtk_major_version, gtk_minor_version,
gtk_micro_version);

   GtkWidget *window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
   gtk_window_set_title(GTK_WINDOW(window), "Notebook Test2");
   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");

   GtkWidget *button1=gtk_button_new_with_label("Properties OK");
   g_signal_connect(button1, "clicked", G_CALLBACK(click_button1), NULL);

   GtkWidget *table1=gtk_table_new(2, 1, FALSE);
   gtk_table_attach(GTK_TABLE(table1), label1, 0, 1, 0, 1, GTK_EXPAND,
GTK_EXPAND, 0, 0);
   gtk_table_attach(GTK_TABLE(table1), button1, 0, 1, 1, 2, GTK_EXPAND,
GTK_SHRINK, 0, 0);

   GtkWidget *font=gtk_font_selection_new();
   g_signal_connect(font, "realize", G_CALLBACK(set_font), NULL);

   GtkWidget *button2=gtk_button_new_with_label("Font OK");
   g_signal_connect(button2, "clicked", G_CALLBACK(click_button2), font);

   GtkWidget *table2=gtk_table_new(2, 1, FALSE);
   gtk_table_attach(GTK_TABLE(table2), font, 0, 1, 0, 1, GTK_EXPAND,
GTK_EXPAND, 0, 0);
   gtk_table_attach(GTK_TABLE(table2), button2, 0, 1, 1, 2, GTK_EXPAND,
GTK_SHRINK, 0, 0);

   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), table1,
notebook_label1);
   gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table2,
notebook_label2);

   gtk_container_add(GTK_CONTAINER(window), notebook);

   gtk_widget_show_all(window);

   gtk_main();
   return 0;
 }





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]