Web lists-archives.com

Re: Font selection panel as part of notebook




Eric,

On Sun, Sep 24, 2017 at 1:47 PM, Igor Korot <ikorot01@xxxxxxxxx> wrote:
> Eric,
>
> On Sun, Sep 24, 2017 at 1:51 AM, Igor Korot <ikorot01@xxxxxxxxx> wrote:
>> Eric,
>>
>> On Sun, Sep 24, 2017 at 12:33 AM,  <cecashon@xxxxxxx> wrote:
>>>
>>> When I test it out it looks like the font selection widget doesn't work very
>>> well in GTK3.
>>>
>>> Not quite sure how you have it setup for GTK2 and what information you are
>>> using to activate the apply button. The GValue that I get returned is a
>>> PangoFcFamily*. I don't think this will help unless you pull in private data
>>> from Pango. You don't like "The quick brown fox..."?
>>
>> This is what I see on the Terminal:
>>
>> igor@IgorDellGentoo ~ $ ./fontsel
>> Cursor Changed
>> 43
>> ((PangoFcFamily*) 0xba5a40)
>> Cursor Changed
>> 43
>> ((PangoFcFamily*) 0xba5a40)
>> Cursor Changed
>> 43
>> ((PangoFcFamily*) 0xba5a40)
>> Cursor Changed
>> 43
>> ((PangoFcFamily*) 0xba5a40)
>> Cursor Changed
>> 44
>> ((PangoFcFamily*) 0xba5a80)
>>
>> It initially selects "Sans" and then I select "Serif".
>>
>> I'm testing with GTK+2.24 on Gentoo Linux.
>
> I was calling "g_value_get_string( &value )" and this function failed.
> That's why I did see
> an empty string.
>
> I didn't look at the GTK+ sources but it looks like the value
> retrieved is just an address
> of the string and not the string itself.
>
> I do have a workaround. I didn't test it yet, but I'd prefer to get
> this info this way.
>
> Is there anything else?

I think I will just create a generic tab that will mimic the behaviour.
The reason being - I don't have access to the "Style" list box.

Now the only thing left is find what styles are available for a specific
font name? Is this info available on the PangoFont?

Thank you.

>
> Thank you.
>
>>
>> Thank you.
>>
>>>
>>> Eric
>>>
>>> /*
>>>    gcc -Wall font_selection1.c -o font_selection1 `pkg-config --cflags
>>> --libs gtk+-3.0`
>>>    gcc -Wall font_selection1.c -o font_selection1 `pkg-config --cflags
>>> --libs gtk+-2.0`
>>>    Tested with GTK3.18 on Ubuntu16.04
>>> */
>>>
>>> #include<gtk/gtk.h>
>>>
>>> static void font_name_change(GtkTreeView *view, gpointer user_data)
>>>   {
>>>     g_print("Cursor Changed\n");
>>>     GtkTreeIter iter;
>>>     GValue value=G_VALUE_INIT;
>>>     GList *selRows = NULL;
>>>     GtkTreeSelection *sel = gtk_tree_view_get_selection( view );
>>>     GtkTreeModel *model = gtk_tree_view_get_model( view );
>>>     selRows = gtk_tree_selection_get_selected_rows( sel, &model );
>>>     if(selRows!=NULL)
>>>       {
>>>         gchar *string1=gtk_tree_path_to_string((GtkTreePath
>>> *)selRows[0].data);
>>>         g_print("%s\n", string1);
>>>         g_free(string1);
>>>         if(gtk_tree_model_get_iter( model, &iter, (GtkTreePath
>>> *)selRows[0].data ))
>>>           {
>>>             gtk_tree_model_get_value( model, &iter, 0, &value );
>>>             gchar *string2=g_strdup_value_contents(&value);
>>>             g_print("%s\n", string2);
>>>             g_free(string2);
>>>           }
>>>         else
>>>           {
>>>             g_print("Need a valid iter.\n");
>>>           }
>>>       }
>>>    else
>>>       {
>>>         g_print("No list.\n");
>>>       }
>>>
>>>    g_list_free_full(selRows, (GDestroyNotify) gtk_tree_path_free);
>>>
>>>   }
>>> 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), "Font Selecton");
>>>     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);
>>>
>>>     G_GNUC_BEGIN_IGNORE_DEPRECATIONS
>>>     GtkWidget *m_fontPanel=gtk_font_selection_new();
>>>     GtkWidget *names = gtk_font_selection_get_family_list((GtkFontSelection
>>> *) m_fontPanel );
>>>     //For GTK3.
>>>     gtk_tree_view_set_activate_on_single_click(GTK_TREE_VIEW(names), TRUE);
>>>     //GtkWidget *sizes = gtk_font_selection_get_size_entry((GtkFontSelection
>>> *) m_fontPanel );
>>>     g_signal_connect( names, "cursor-changed", G_CALLBACK(font_name_change),
>>> NULL );
>>>     G_GNUC_END_IGNORE_DEPRECATIONS
>>>
>>>     gtk_container_add(GTK_CONTAINER(window), m_fontPanel);
>>>
>>>     gtk_widget_show_all(window);
>>>
>>>     gtk_main();
>>>
>>>     return 0;
>>>   }
>>>
>>>
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list