<pre><code>
GtkWidget *mono_chbn, *prop_chbn;  //check_buttons pointers
gint mono_response, prop_response; //response_id for the checkbuttons

//will be needed by filter function
struct Data {
  gboolean mono_checked; // checked/active state of Ist check_button
  gboolean prop_checked;
  char previous_family[50]; // stores the family name of the font 
  // encountered by gtk_font_chooser_set_filter_func()
}filter_data;

//the filter function 
//(https://developer.gnome.org/gtk3/stable/GtkFontChooser.html#GtkFontFilterFunc)

// it will be called by gtk-font-chooser-set-filter-func,
// https://developer.gnome.org/gtk3/stable/GtkFontChooser.html#gtk-font-chooser-set-filter-func , 
// so should probabably keep the same number and kind of arguments as 
// described there.
gboolean check_filter (const PangoFontFamily *family, 
        // family=related group of faces, of varying slant, weight, width 
        // and other aspects
                      const PangoFontFace *face, 
        // within a face only size varies; NOT USED here; 
        // but probably should not remove this parameter in any case.
                      struct Data *filter_data); // gpointer user_data 
    char current_family[]=pango_font_family_get_name (family); 
    
    if (strcmp(current_family, filter_data->previous_family){ 
                //strings not equal returns 1, so consider admiting the font
                strcpy( filter_data->previous_family, current_family);
                // https://developer.gnome.org/pango/stable/pango-Fonts.html#pango-font-family-is-monospace
                if(pango_font_family_is_monospace (family);){
                        return (filter_data -> mono_checked)
                }else{
                        return (filter_data -> mono_checked)
                }
        }else{
                return FALSE //current font is of same family as previous
        }
}


//creating the buttons

mono_chbn=gtk_check_button_new_with_label ("Monospaced"); 
// returns GtkWidget *; makes label to right of check button
gtk_toggle_button_set_mode (mono_chbn,  TRUE);                  
// with  indicator; Default value: FALSE
mono_response=1;

prop_chbn=gtk_check_button_new_with_label ("Proportional"); 
//places a discrete GtkToggleButton next to a widget, (usually a GtkLabel).
gtk_toggle_button_set_mode (mono_chbn, TRUE); 
prop_response=2;

// adding them to Geany gtkFontchooser dialog
gtk_dialog_add_action_widget (FontChooserDG, mono_chbn, mono_response); 
//when mono_chbn clicked (checked), will make the dialog emit signal 
//"response" with response ID mono_response 
gtk_dialog_add_action_widget (FontChooserDG,  prop_chbn, mono_response);                


// AT OPENING FontChooserDG dialog: (by clicking GtkFontButton)

gboolean saved_mono_state="load from some saved Geany intersession file ";  
// don't know how it's done, but I guess should be done
gboolean saved_prop_state="load from some saved Geany intersession file ";

gtk_toggle_button_set_active (mono_chbn, saved_mono_state);
gtk_toggle_button_set_active (prop_chbn, saved_prop_state);

// Filtering of the fonts before user starts clicking inside the 
// opened font Chooser dialog

strcpy( filter_data.previous_family, ""); 
// or some other string that's not going to be any valid family font name
filter_data.mono_checked = gtk_toggle_button_get_active (mono_chbn);
filter_data.prop_checked = gtk_toggle_button_get_active (prop_chbn);

// QUESTION: here 
// https://developer.gnome.org/gtk3/stable/GtkFontChooser.html#gtk-font-chooser-set-filter-func 
// says "Adds a filter function that decides which fonts to display 
// in the font chooser." -- is it meant it only adds/sets/connects the 
//filter, or actually applies the filter (and does the filtering) 
//when called? I interpreted in IInd way..

if(filter_data.mono_checked || filter_data.prop_checked){ 
        gtk_font_chooser_set_filter_func (fontchooserInterface, 
                                          @check_filter,  
                                          @filter_data,  
                                          NULL); //GDestroyNotify destroy; 
                                                  // It seemed not needed that's why I set NULL
}else{ // when both buttons unchecked, 
                //don't waste time running the filter in vain
        "display empty list of fonts;" // don't know how it's done 
}

gtk_widget_show_all (FontChooserDG);


// REACTING to activation of checkbuttons in the dialog

//// QUESTION: 
// should the program react by "connecting" signals from buttons with 
//some functions (as I see in such examples 
// https://python-gtk-3-tutorial.readthedocs.io/en/latest/button_widgets.html), 
//or by using gtk_dialog_run() with emmitted response signal with 
// response_ID, as  
//https://developer.gnome.org/gtk3/stable/GtkDialog.html#gtk-dialog-run 
// ? Or is it that the latter is only good if one wants a "modal dialog" 
//(i.e, that is, one which freezes the rest of the application from 
// user input)? 
//  Anyway, I did it in the IIn way...


while (FontChooserDG != NULL){  //i.e while FontChooserDG still exists
        gint responseID = gtk_dialog_run (FontChooserDG); 
        //runs a recursive main loop until the dialog either emits 
        // the “response” signal, or is destroyed. 
        
        if (responseID==mono_response || responseID==prop_response  ) { 
                // if any of mono/prop checkbuttons activated
                strcpy( filter_data.previous_family, "");
                filter_data.mono_checked = gtk_toggle_button_get_active (mono_chbn);
                filter_data.prop_checked = gtk_toggle_button_get_active (prop_chbn);
                if(filter_data.mono_checked || filter_data.prop_checked){ 
                gtk_font_chooser_set_filter_func (fontchooserInterface, 
                                                                                //GtkFontChooser *fontchooser,
                                                  @check_filter
                                                  @filter_data,  
                                                  NULL); 
                }else{ // when both buttons unchecked, 
                        //don't waste time running the filter in vain
                        "display empty list of fonts;" // I don't know how 
                }
        }else if ("some other widgets within FontChooserDG were activated"){  
           //do_widget_specific_something ();
        }else {
           // assuming_dialog_was_cancelled ();
           "save the check-state of both checkbuttons in some Geany intersession file"  
           // however it is done
                gtk_widget_destroy (FontChooserDG);
        }

}//while

</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany/issues/1928#issuecomment-416014264">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABDrJz5-EcwKL4NwmrhFZ_6SueLv01Mkks5uUivDgaJpZM4WGvIU">mute the thread</a>.<img src="https://github.com/notifications/beacon/ABDrJ-80UqMU_DN1jPp3p-iW7KM_G6ulks5uUivDgaJpZM4WGvIU.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/geany/geany","title":"geany/geany","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/geany/geany"}},"updates":{"snippets":[{"icon":"PERSON","message":"@VictorelPetrovich in #1928: ```\r\n\r\nGtkWidget *mono_chbn, *prop_chbn;  //check_buttons pointers\r\ngint mono_response, prop_response; //response_id for the checkbuttons\r\n\r\n//will be needed by filter function\r\nstruct Data {\r\n  gboolean mono_checked; // checked/active state of Ist check_button\r\n  gboolean prop_checked;\r\n  char previous_family[50]; // stores the family name of the font \r\n  // encountered by gtk_font_chooser_set_filter_func()\r\n}filter_data;\r\n\r\n//the filter function \r\n//(https://developer.gnome.org/gtk3/stable/GtkFontChooser.html#GtkFontFilterFunc)\r\n\r\n// it will be called by gtk-font-chooser-set-filter-func,\r\n// https://developer.gnome.org/gtk3/stable/GtkFontChooser.html#gtk-font-chooser-set-filter-func , \r\n// so should probabably keep the same number and kind of arguments as \r\n// described there.\r\ngboolean check_filter (const PangoFontFamily *family, \r\n\t// family=related group of faces, of varying slant, weight, width \r\n\t// and other aspects\r\n                      const PangoFontFace *face, \r\n\t// within a face only size varies; NOT USED here; \r\n\t// but probably should not remove this parameter in any case.\r\n                      struct Data *filter_data); // gpointer user_data \r\n    char current_family[]=pango_font_family_get_name (family); \r\n    \r\n    if (strcmp(current_family, filter_data-\u003eprevious_family){ \r\n\t\t//strings not equal returns 1, so consider admiting the font\r\n\t\tstrcpy( filter_data-\u003eprevious_family, current_family);\r\n\t\t// https://developer.gnome.org/pango/stable/pango-Fonts.html#pango-font-family-is-monospace\r\n\t\tif(pango_font_family_is_monospace (family);){\r\n\t\t\treturn (filter_data -\u003e mono_checked)\r\n\t\t}else{\r\n\t\t\treturn (filter_data -\u003e mono_checked)\r\n\t\t}\r\n\t}else{\r\n\t\treturn FALSE //current font is of same family as previous\r\n\t}\r\n}\r\n\r\n\r\n//creating the buttons\r\n\r\nmono_chbn=gtk_check_button_new_with_label (\"Monospaced\"); \r\n// returns GtkWidget *; makes label to right of check button\r\ngtk_toggle_button_set_mode (mono_chbn, \tTRUE); \t\t\t\r\n// with  indicator; Default value: FALSE\r\nmono_response=1;\r\n\r\nprop_chbn=gtk_check_button_new_with_label (\"Proportional\"); \r\n//places a discrete GtkToggleButton next to a widget, (usually a GtkLabel).\r\ngtk_toggle_button_set_mode (mono_chbn, TRUE); \r\nprop_response=2;\r\n\r\n// adding them to Geany gtkFontchooser dialog\r\ngtk_dialog_add_action_widget (FontChooserDG, mono_chbn, mono_response);\t\r\n//when mono_chbn clicked (checked), will make the dialog emit signal \r\n//\"response\" with response ID mono_response \r\ngtk_dialog_add_action_widget (FontChooserDG,  prop_chbn, mono_response);\t\t\r\n\r\n\r\n// AT OPENING FontChooserDG dialog: (by clicking GtkFontButton)\r\n\r\ngboolean saved_mono_state=\"load from some saved Geany intersession file \";  \r\n// don't know how it's done, but I guess should be done\r\ngboolean saved_prop_state=\"load from some saved Geany intersession file \";\r\n\r\ngtk_toggle_button_set_active (mono_chbn, saved_mono_state);\r\ngtk_toggle_button_set_active (prop_chbn, saved_prop_state);\r\n\r\n// Filtering of the fonts before user starts clicking inside the \r\n// opened font Chooser dialog\r\n\r\nstrcpy( filter_data.previous_family, \"\"); \r\n// or some other string that's not going to be any valid family font name\r\nfilter_data.mono_checked = gtk_toggle_button_get_active (mono_chbn);\r\nfilter_data.prop_checked = gtk_toggle_button_get_active (prop_chbn);\r\n\r\n// QUESTION: here \r\n// https://developer.gnome.org/gtk3/stable/GtkFontChooser.html#gtk-font-chooser-set-filter-func \r\n// says \"Adds a filter function that decides which fonts to display \r\n// in the font chooser.\" -- is it meant it only adds/sets/connects the \r\n//filter, or actually applies the filter (and does the filtering) \r\n//when called? I interpreted in IInd way..\r\n\r\nif(filter_data.mono_checked || filter_data.prop_checked){ \r\n\tgtk_font_chooser_set_filter_func (fontchooserInterface, \r\n\t                                  @check_filter,  \r\n\t                                  @filter_data,  \r\n\t                                  NULL); //GDestroyNotify destroy; \r\n\t\t\t\t\t\t  // It seemed not needed that's why I set NULL\r\n}else{ // when both buttons unchecked, \r\n\t\t//don't waste time running the filter in vain\r\n\t\"display empty list of fonts;\" // don't know how it's done \r\n}\r\n\r\ngtk_widget_show_all (FontChooserDG);\r\n\r\n\r\n// REACTING to activation of checkbuttons in the dialog\r\n\r\n//// QUESTION: \r\n// should the program react by \"connecting\" signals from buttons with \r\n//some functions (as I see in such examples \r\n// https://python-gtk-3-tutorial.readthedocs.io/en/latest/button_widgets.html), \r\n//or by using gtk_dialog_run() with emmitted response signal with \r\n// response_ID, as  \r\n//https://developer.gnome.org/gtk3/stable/GtkDialog.html#gtk-dialog-run \r\n// ? Or is it that the latter is only good if one wants a \"modal dialog\" \r\n//(i.e, that is, one which freezes the rest of the application from \r\n// user input)? \r\n//  Anyway, I did it in the IIn way...\r\n\r\n\r\nwhile (FontChooserDG != NULL){\t//i.e while FontChooserDG still exists\r\n\tgint responseID = gtk_dialog_run (FontChooserDG); \r\n\t//runs a recursive main loop until the dialog either emits \r\n\t// the “response” signal, or is destroyed. \r\n\t\r\n\tif (responseID==mono_response || responseID==prop_response  ) { \r\n\t\t// if any of mono/prop checkbuttons activated\r\n\t\tstrcpy( filter_data.previous_family, \"\");\r\n\t\tfilter_data.mono_checked = gtk_toggle_button_get_active (mono_chbn);\r\n\t\tfilter_data.prop_checked = gtk_toggle_button_get_active (prop_chbn);\r\n\t\tif(filter_data.mono_checked || filter_data.prop_checked){ \r\n\t\tgtk_font_chooser_set_filter_func (fontchooserInterface, \r\n\t\t\t\t\t\t\t\t\t\t//GtkFontChooser *fontchooser,\r\n\t\t                                  @check_filter\r\n\t\t                                  @filter_data,  \r\n\t\t                                  NULL); \r\n\t\t}else{ // when both buttons unchecked, \r\n\t\t\t//don't waste time running the filter in vain\r\n\t\t\t\"display empty list of fonts;\" // I don't know how \r\n\t\t}\r\n\t}else if (\"some other widgets within FontChooserDG were activated\"){\t\r\n\t   //do_widget_specific_something ();\r\n\t}else {\r\n\t   // assuming_dialog_was_cancelled ();\r\n\t   \"save the check-state of both checkbuttons in some Geany intersession file\"  \r\n\t   // however it is done\r\n\t\tgtk_widget_destroy (FontChooserDG);\r\n\t}\r\n\r\n}//while\r\n\r\n```"}],"action":{"name":"View Issue","url":"https://github.com/geany/geany/issues/1928#issuecomment-416014264"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/geany/geany/issues/1928#issuecomment-416014264",
"url": "https://github.com/geany/geany/issues/1928#issuecomment-416014264",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
},
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"hideOriginalBody": "false",
"originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB",
"title": "Re: [geany/geany] choose font: classify families into monospace/proportional (#1928)",
"sections": [
{
"text": "",
"activityTitle": "**VictorelPetrovich**",
"activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png",
"activitySubtitle": "@VictorelPetrovich",
"facts": [

]
}
],
"potentialAction": [
{
"name": "Add a comment",
"@type": "ActionCard",
"inputs": [
{
"isMultiLine": true,
"@type": "TextInput",
"id": "IssueComment",
"isRequired": false
}
],
"actions": [
{
"name": "Comment",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"geany/geany\",\n\"issueId\": 1928,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}"
}
]
},
{
"name": "Close issue",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueClose\",\n\"repositoryFullName\": \"geany/geany\",\n\"issueId\": 1928\n}"
},
{
"targets": [
{
"os": "default",
"uri": "https://github.com/geany/geany/issues/1928#issuecomment-416014264"
}
],
"@type": "OpenUri",
"name": "View on GitHub"
},
{
"name": "Unsubscribe",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 370864660\n}"
}
],
"themeColor": "26292E"
}
]</script>