Frequency change by a mouse wheel

upup

Now you can change the frequency by your mouse wheel. So almost all is done except for the artistic elaboration.

static gboolean cb_mouse_event(GtkWidget *widget, GdkEventScroll *event, gpointer data) { 
    double ifreq_delta;
    int index;
    index = ( 636 - (int) event->x ) / 28; 
    if(index < 0) index = 0;
    if(index > 7) index = 7;
    ifreq_delta = pow(10.0, (double) index); 
    if( (event->direction) == 0 ) {
        ifreq_in_hz += ifreq_delta;
    } else {
        ifreq_in_hz -= ifreq_delta;
    }
    set_freq(ifreq_in_hz);
    return FALSE;
}

The code needs some technical elaboration in converting mouse location to the incremental value of the frequency.

/* main */
    gtk_widget_add_events(drawing_area, GDK_SCROLL_MASK);
    g_signal_connect(G_OBJECT (drawing_area), "scroll-event", G_CALLBACK (cb_mouse_event), NULL);

Front Panel Design

panel2

It does not look very cool, but is quite acceptable. Do you agree?

struct radio_button {
    int  nbutton;
    char name[32][128];
};

int ngroup = 6;
struct radio_button my_radio_buttons[128] = {
     {2, {"CW", "CW-REV"} },
     {7, {"10 wpm", "15 wpm", "20 wpm", "25 wpm", "30 wpm", "35 wpm", "40 wpm"} },
     {3, {"TX OFF", "BK-IN" , "FBK-IN"} },
     {3, {"IF FIL1", "IF FIL2" , "IF FIL3"} },
     {4, {"PRE-AMP OFF", "PRE-AMP 1" , "PRE-AMP 2", "ATT ON"} }, 
     {8, {" 3501.000kHz", " 7026.000kHz", "10118.000kHz", "14058.000kHz",
          "18085.000kHz", "21058.000kHz", "24908.000kHz", "28058.000kHz"} },
};

This is to define radio buttons.

    GtkWidget *hbox_radio, *vbox_radio;
    hbox_radio = gtk_hbox_new(FALSE, 5);
    for(int j=0;j<ngroup;j++) {
        vbox_radio = gtk_vbox_new(FALSE, 5);
        for(int i=0;i<my_radio_buttons[j].nbutton;i++) {
            if(i == 0) {
                button = gtk_radio_button_new_with_label(NULL,
                         my_radio_buttons[j].name[i]);
            } else {
                button = gtk_radio_button_new_with_label(gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
                         my_radio_buttons[j].name[i]);
            }
            gtk_signal_connect (GTK_OBJECT (button), "toggled", GTK_SIGNAL_FUNC (callback),
            (gpointer) my_radio_buttons[j].name[i]);
            gtk_box_pack_start (GTK_BOX (vbox_radio), button, FALSE, FALSE, 0);
            gtk_widget_show (button);
        }
        gtk_box_pack_start (GTK_BOX (hbox_radio), vbox_radio, FALSE, FALSE, 0);
    }

And this is for drawing the buttons. The names of the buttons must be unique, because they all connected to the same callback routine.