void i_configure_gui( void ) { static GtkWidget *configwin = NULL; GdkGeometry cw_hints; GtkWidget *configwin_vbox; GtkWidget *hseparator, *hbuttonbox, *button_ok, *button_cancel, *button_apply; GtkWidget *configwin_notebook; GtkWidget *ap_page_alignment, *ap_pagelabel_alignment; /* amidi-plug */ GtkWidget *alsa_page_alignment, *alsa_pagelabel_alignment; /* alsa */ GtkWidget *fsyn_page_alignment, *fsyn_pagelabel_alignment; /* fluidsynth */ GSList *backend_list = NULL, *backend_list_h = NULL; if ( configwin != NULL ) { DEBUGMSG( "config window is already open!\n" ); return; } /* get configuration information for backends */ i_configure_cfg_backend_alloc(); i_configure_cfg_backend_read(); configwin = gtk_window_new( GTK_WINDOW_TOPLEVEL ); gtk_window_set_type_hint( GTK_WINDOW(configwin), GDK_WINDOW_TYPE_HINT_DIALOG ); gtk_window_set_title( GTK_WINDOW(configwin), _("AMIDI-Plug - configuration") ); gtk_container_set_border_width( GTK_CONTAINER(configwin), 10 ); g_signal_connect( G_OBJECT(configwin) , "destroy" , G_CALLBACK(gtk_widget_destroyed) , &configwin ); button_ok = gtk_button_new_from_stock( GTK_STOCK_OK ); if (! g_signal_lookup ("ap-commit", G_OBJECT_TYPE (button_ok))) g_signal_new ("ap-commit", G_OBJECT_TYPE (button_ok), G_SIGNAL_ACTION, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); g_signal_connect (button_ok, "clicked", (GCallback) commit_cb, NULL); cw_hints.min_width = 480; cw_hints.min_height = -1; gtk_window_set_geometry_hints( GTK_WINDOW(configwin) , GTK_WIDGET(configwin) , &cw_hints , GDK_HINT_MIN_SIZE ); configwin_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0 ); gtk_container_add( GTK_CONTAINER(configwin) , configwin_vbox ); configwin_notebook = gtk_notebook_new(); gtk_notebook_set_tab_pos( GTK_NOTEBOOK(configwin_notebook) , GTK_POS_LEFT ); gtk_box_pack_start( GTK_BOX(configwin_vbox) , configwin_notebook , TRUE , TRUE , 2 ); /* GET A LIST OF BACKENDS */ backend_list = i_backend_list_lookup(); /* get a list of available backends */; backend_list_h = backend_list; /* AMIDI-PLUG PREFERENCES TAB */ ap_pagelabel_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 ); ap_page_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 ); gtk_alignment_set_padding( GTK_ALIGNMENT(ap_page_alignment) , 3 , 3 , 8 , 3 ); i_configure_gui_tab_ap( ap_page_alignment , backend_list , button_ok ); i_configure_gui_tablabel_ap( ap_pagelabel_alignment , backend_list , button_ok ); gtk_notebook_append_page( GTK_NOTEBOOK(configwin_notebook) , ap_page_alignment , ap_pagelabel_alignment ); /* ALSA BACKEND CONFIGURATION TAB */ alsa_pagelabel_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 ); alsa_page_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 ); gtk_alignment_set_padding( GTK_ALIGNMENT(alsa_page_alignment) , 3 , 3 , 8 , 3 ); i_configure_gui_tab_alsa( alsa_page_alignment , backend_list , button_ok ); i_configure_gui_tablabel_alsa( alsa_pagelabel_alignment , backend_list , button_ok ); gtk_notebook_append_page( GTK_NOTEBOOK(configwin_notebook) , alsa_page_alignment , alsa_pagelabel_alignment ); /* FLUIDSYNTH BACKEND CONFIGURATION TAB */ fsyn_pagelabel_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 ); fsyn_page_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 ); gtk_alignment_set_padding( GTK_ALIGNMENT(fsyn_page_alignment) , 3 , 3 , 8 , 3 ); i_configure_gui_tab_fsyn( fsyn_page_alignment , backend_list , button_ok ); i_configure_gui_tablabel_fsyn( fsyn_pagelabel_alignment , backend_list , button_ok ); gtk_notebook_append_page( GTK_NOTEBOOK(configwin_notebook) , fsyn_page_alignment , fsyn_pagelabel_alignment ); i_backend_list_free( backend_list_h ); /* done, free the list of available backends */ /* horizontal separator and buttons */ hseparator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); gtk_box_pack_start( GTK_BOX(configwin_vbox) , hseparator , FALSE , FALSE , 4 ); hbuttonbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); gtk_button_box_set_layout( GTK_BUTTON_BOX(hbuttonbox) , GTK_BUTTONBOX_END ); button_apply = gtk_button_new_from_stock( GTK_STOCK_APPLY ); gtk_container_add( GTK_CONTAINER(hbuttonbox) , button_apply ); button_cancel = gtk_button_new_from_stock( GTK_STOCK_CANCEL ); g_signal_connect_swapped( G_OBJECT(button_cancel) , "clicked" , G_CALLBACK(i_configure_ev_bcancel) , configwin ); gtk_container_add( GTK_CONTAINER(hbuttonbox) , button_cancel ); /* button_ok = gtk_button_new_from_stock( GTK_STOCK_OK ); created above */ g_object_set_data( G_OBJECT(button_ok) , "bapply_pressed" , GUINT_TO_POINTER(0) ); g_object_set_data( G_OBJECT(button_apply) , "bok" , button_ok ); g_signal_connect( G_OBJECT(button_ok) , "ap-commit" , G_CALLBACK(i_configure_ev_bok) , configwin ); g_signal_connect( G_OBJECT(button_apply) , "clicked" , G_CALLBACK(i_configure_ev_bapply) , configwin ); gtk_container_add( GTK_CONTAINER(hbuttonbox) , button_ok ); gtk_box_pack_start( GTK_BOX(configwin_vbox) , hbuttonbox , FALSE , FALSE , 0 ); gtk_widget_show_all( configwin ); }
void i_configure_gui( void ) { static GtkWidget *configwin = NULL; if ( configwin != NULL ) { DEBUGMSG( "config window is already open!\n" ); return; } /* get configuration information for backends */ i_configure_cfg_backend_alloc(); i_configure_cfg_backend_read(); configwin = gtk_dialog_new_with_buttons (_("AMIDI-Plug Settings"), NULL, 0, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); if (! g_signal_lookup ("ap-commit", G_OBJECT_TYPE (configwin))) g_signal_new ("ap-commit", G_OBJECT_TYPE (configwin), G_SIGNAL_ACTION, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); g_signal_connect (configwin, "response", (GCallback) response_cb, NULL); g_signal_connect (configwin, "destroy", (GCallback) gtk_widget_destroyed, & configwin); GtkWidget * configwin_vbox = gtk_dialog_get_content_area ((GtkDialog *) configwin); GtkWidget * configwin_notebook = gtk_notebook_new (); gtk_notebook_set_tab_pos( GTK_NOTEBOOK(configwin_notebook) , GTK_POS_LEFT ); gtk_box_pack_start( GTK_BOX(configwin_vbox) , configwin_notebook , TRUE , TRUE , 2 ); /* GET A LIST OF BACKENDS */ GSList * backend_list = i_backend_list_lookup (); GSList * backend_list_h = backend_list; /* AMIDI-PLUG PREFERENCES TAB */ GtkWidget * ap_pagelabel_alignment = gtk_alignment_new (0.5, 0.5, 1, 1); GtkWidget * ap_page_alignment = gtk_alignment_new (0.5, 0.5, 1, 1); gtk_alignment_set_padding( GTK_ALIGNMENT(ap_page_alignment) , 3 , 3 , 8 , 3 ); i_configure_gui_tab_ap (ap_page_alignment, backend_list, configwin); i_configure_gui_tablabel_ap (ap_pagelabel_alignment, backend_list, configwin); gtk_notebook_append_page( GTK_NOTEBOOK(configwin_notebook) , ap_page_alignment , ap_pagelabel_alignment ); #ifdef AMIDIPLUG_ALSA /* ALSA BACKEND CONFIGURATION TAB */ GtkWidget * alsa_pagelabel_alignment = gtk_alignment_new (0.5, 0.5, 1, 1); GtkWidget * alsa_page_alignment = gtk_alignment_new (0.5, 0.5, 1, 1); gtk_alignment_set_padding( GTK_ALIGNMENT(alsa_page_alignment) , 3 , 3 , 8 , 3 ); i_configure_gui_tab_alsa (alsa_page_alignment, backend_list, configwin); i_configure_gui_tablabel_alsa (alsa_pagelabel_alignment, backend_list, configwin); gtk_notebook_append_page( GTK_NOTEBOOK(configwin_notebook) , alsa_page_alignment , alsa_pagelabel_alignment ); #endif /* AMIDIPLUG_ALSA */ #if AMIDIPLUG_FLUIDSYNTH /* FLUIDSYNTH BACKEND CONFIGURATION TAB */ GtkWidget * fsyn_pagelabel_alignment = gtk_alignment_new (0.5, 0.5, 1, 1); GtkWidget * fsyn_page_alignment = gtk_alignment_new (0.5, 0.5, 1, 1); gtk_alignment_set_padding( GTK_ALIGNMENT(fsyn_page_alignment) , 3 , 3 , 8 , 3 ); i_configure_gui_tab_fsyn (fsyn_page_alignment, backend_list, configwin); i_configure_gui_tablabel_fsyn (fsyn_pagelabel_alignment, backend_list, configwin); gtk_notebook_append_page( GTK_NOTEBOOK(configwin_notebook) , fsyn_page_alignment , fsyn_pagelabel_alignment ); #endif i_backend_list_free( backend_list_h ); /* done, free the list of available backends */ gtk_widget_show_all( configwin ); }