Exemplo n.º 1
0
void pVerticalSlider::constructor() {
  gtkWidget = gtk_vscale_new_with_range(0, 100, 1);
  gtk_scale_set_draw_value(GTK_SCALE(gtkWidget), false);
  g_signal_connect_swapped(G_OBJECT(gtkWidget), "value-changed", G_CALLBACK(VerticalSlider_change), (gpointer)&verticalSlider);

  setLength(verticalSlider.state.length);
  setPosition(verticalSlider.state.position);
}
Exemplo n.º 2
0
GtkWidget *widget_hscale_create(
	AttributeSet *Attr, tag_attr *attr, gint Type)
{
	GtkWidget        *widget;
	gdouble           range_min = 0;
	gdouble           range_max = 100;
	gdouble           range_step = 1;
	gdouble           range_value = 0;
	gchar            *value;

#ifdef DEBUG_TRANSITS
	fprintf(stderr, "%s(): Entering.\n", __func__);
#endif

	/* Thunor: These "range-*" names are consistent with the spinbutton widget */
	if (attr) {
		if (!(value = get_tag_attribute(attr, "range-min")))
			value = get_tag_attribute(attr, "scale-min");
		if (value) range_min = atof(value);

		if (!(value = get_tag_attribute(attr, "range-max")))
			value = get_tag_attribute(attr, "scale-max");
		if (value) range_max = atof(value);

		if (!(value = get_tag_attribute(attr, "range-step")))
			value = get_tag_attribute(attr, "scale-step");
		if (value) range_step = atof(value);

		if (!(value = get_tag_attribute(attr, "range-value")))
			value = get_tag_attribute(attr, "scale-value");
		if (value) range_value = atof(value);
	}

	if (Type == WIDGET_HSCALE) {
#if !GTK_CHECK_VERSION(3,0,0)	/* gtk3: Deprecated in gtk3 so I've added the newly recommended equivalent */
		widget = gtk_hscale_new_with_range(range_min, range_max, range_step);
#else
		widget = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, range_min, range_max, range_step);
#endif
	} else {
#if !GTK_CHECK_VERSION(3,0,0)	/* gtk3: Deprecated in gtk3 so I've added the newly recommended equivalent */
		widget = gtk_vscale_new_with_range(range_min, range_max, range_step);
#else
		widget = gtk_scale_new_with_range(GTK_ORIENTATION_VERTICAL, range_min, range_max, range_step);
#endif
	}
	gtk_range_set_value(GTK_RANGE(widget), range_value);

#ifdef DEBUG_TRANSITS
	fprintf(stderr, "%s(): Exiting.\n", __func__);
#endif

	return widget;
}
Exemplo n.º 3
0
VolBox *lamixer_volbox_new(const gchar *str, const gint mono, const gint mute, const glong minrange, const glong maxrange, snd_mixer_elem_t *elem, guint voltype)
{
	VolBox *volumebox;

	volumebox = g_malloc(sizeof(VolBox));
	volumebox->minrange = minrange;
	volumebox->maxrange = maxrange;
	volumebox->type = voltype;
	volumebox->volelem = elem;
	volumebox->volbox = gtk_vbox_new(FALSE,0);
	volumebox->volbarbox = gtk_hbox_new(FALSE,0);
	volumebox->vollabel = gtk_label_new(str);
	volumebox->volbar = gtk_vscale_new_with_range(minrange,maxrange,1.0);
	gtk_range_set_inverted(GTK_RANGE(volumebox->volbar), TRUE);
	gtk_scale_set_digits(GTK_SCALE(volumebox->volbar),0);
	gtk_scale_set_value_pos(GTK_SCALE(volumebox->volbar),GTK_POS_BOTTOM);
	//FIXME: Need any other method to set size
	gtk_widget_set_size_request(GTK_WIDGET(volumebox->volbar),0,200);
	if (!mono) {
		volumebox->rvolbar = gtk_vscale_new_with_range(minrange,maxrange,1.0);
		gtk_scale_set_digits(GTK_SCALE(volumebox->rvolbar),0);
		gtk_range_set_inverted(GTK_RANGE(volumebox->rvolbar), TRUE);
		gtk_scale_set_value_pos(GTK_SCALE(volumebox->rvolbar),GTK_POS_BOTTOM);
		gtk_widget_set_size_request(GTK_WIDGET(volumebox->rvolbar),0,200);
		volumebox->lockswitch = gtk_check_button_new_with_label("Lock");
	}
	else {
		volumebox->rvolbar = NULL;
		volumebox->lockswitch = NULL;
	}

	if (mute)
		volumebox->muteswitch = gtk_check_button_new_with_label("Mute");
	else
		volumebox->muteswitch = NULL;

	return volumebox;
}
Exemplo n.º 4
0
native_handle _chisel_native_slider_create( int type ) {
	GtkWidget *widget;
	
	if ( type == SliderTypeHorizontal ) {
		widget = gtk_hscale_new_with_range( 0, 1, 0.001 );
	} else {
		widget = gtk_vscale_new_with_range( 0, 1, 0.001 );
	}
	
	gtk_scale_set_draw_value( GTK_SCALE(widget), FALSE );
	
	g_signal_connect( G_OBJECT(widget), "value_changed", G_CALLBACK(_chisel_gtk_slider_changed_event), NULL );
	
	return (native_handle)widget;
}
Exemplo n.º 5
0
/*#
    @method new_with_range GtkVScale
    @brief Creates a new vertical scale widget that lets the user input a number between min and max (including min and max) with the increment step.
    @param min minimum value
    @param max maximum value
    @param step step increment (tick size) used with keyboard shortcuts
    @return a new GtkVScale

    step must be nonzero; it's the distance the slider moves when using the arrow
    keys to adjust the scale value.

    Note that the way in which the precision is derived works best if step is a
    power of ten. If the resulting precision is not suitable for your needs,
    use gtk_scale_set_digits() to correct it.
 */
FALCON_FUNC VScale::new_with_range( VMARG )
{
    Item* i_min = vm->param( 0 );
    Item* i_max = vm->param( 1 );
    Item* i_step = vm->param( 2 );
#ifndef NO_PARAMETER_CHECK
    if ( !i_min || !i_min->isOrdinal()
        || !i_max || !i_max->isOrdinal()
        || !i_step || !i_step->isOrdinal() )
        throw_inv_params( "O,O,O" );
#endif
    GtkWidget* wdt = gtk_vscale_new_with_range( i_min->forceNumeric(),
                                                i_max->forceNumeric(),
                                                i_step->forceNumeric() );
    vm->retval( new Gtk::VScale( vm->findWKI( "GtkVScale" )->asClass(), (GtkVScale*) wdt ) );
}
Exemplo n.º 6
0
GtkWidget *widget_hscale_create(
	AttributeSet *Attr, tag_attr *attr, gint Type)
{
	GtkWidget        *widget;
	gdouble           range_min = 0;
	gdouble           range_max = 100;
	gdouble           range_step = 1;
	gdouble           range_value = 0;
	gchar            *value;

#ifdef DEBUG_TRANSITS
	fprintf(stderr, "%s(): Entering.\n", __func__);
#endif

	/* Thunor: These "range-*" names are consistent with the spinbutton widget */
	if (attr) {
		if (!(value = get_tag_attribute(attr, "range-min")))
			value = get_tag_attribute(attr, "scale-min");
		if (value) range_min = atof(value);

		if (!(value = get_tag_attribute(attr, "range-max")))
			value = get_tag_attribute(attr, "scale-max");
		if (value) range_max = atof(value);

		if (!(value = get_tag_attribute(attr, "range-step")))
			value = get_tag_attribute(attr, "scale-step");
		if (value) range_step = atof(value);

		if (!(value = get_tag_attribute(attr, "range-value")))
			value = get_tag_attribute(attr, "scale-value");
		if (value) range_value = atof(value);
	}

	if (Type == WIDGET_HSCALE) {
		widget = gtk_hscale_new_with_range(range_min, range_max, range_step);
	} else {
		widget = gtk_vscale_new_with_range(range_min, range_max, range_step);
	}
	gtk_range_set_value(GTK_RANGE(widget), range_value);

#ifdef DEBUG_TRANSITS
	fprintf(stderr, "%s(): Exiting.\n", __func__);
#endif

	return widget;
}
Exemplo n.º 7
0
JNIEXPORT jlong JNICALL
Java_org_gnome_gtk_GtkVScale_gtk_1vscale_1new_1with_1range
(
	JNIEnv* env,
	jclass cls,
	jdouble _min,
	jdouble _max,
	jdouble _step
)
{
	GtkWidget* result;
	jlong _result;
	gdouble min;
	gdouble max;
	gdouble step;

	// convert parameter min
	min = (gdouble) _min;

	// convert parameter max
	max = (gdouble) _max;

	// convert parameter step
	step = (gdouble) _step;

	// call function
	result = gtk_vscale_new_with_range(min, max, step);

	// cleanup parameter min

	// cleanup parameter max

	// cleanup parameter step

	// translate return value to JNI type
	_result = (jlong) result;

	// cleanup return value
	if (result != NULL) {
		bindings_java_memory_cleanup((GObject*)result, TRUE);
	}

	// and finally
	return _result;
}
static void
rf_mixer_init (RfMixer *rmix) {
	
	GtkWidget *but = GTK_WIDGET (rmix);
	GtkWidget *image = gtk_image_new_from_stock ("gtk-index", GTK_ICON_SIZE_BUTTON);
	
	gtk_container_add (GTK_CONTAINER (rmix), image);
	
	rmix->scale  = gtk_vscale_new_with_range (0, 100, 1);
	g_object_ref(rmix->scale);
	
	gtk_scale_set_draw_value (GTK_SCALE (rmix->scale), FALSE);

	g_signal_connect (GTK_OBJECT (rmix->scale), "button-release-event", G_CALLBACK (rf_mixer_button_release), rmix);
	//g_signal_connect (GTK_OBJECT (rmix), "activate", G_CALLBACK (rf_mixer_activate), rmix);
	//g_signal_connect (GTK_OBJECT (rmix), "clicked", G_CALLBACK (rf_mixer_activate), rmix);
	//g_signal_connect (GTK_OBJECT (rmix), "pressed", G_CALLBACK (rf_mixer_activate), rmix);

}
Exemplo n.º 9
0
static VALUE
rg_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE arg1, arg2, arg3;
    GtkAdjustment *adj = NULL;
    GtkWidget *widget;

    rb_scan_args(argc, argv, "03", &arg1, &arg2, &arg3);

    if (NIL_P(arg1) || RVAL2GTYPE(arg1) == GTK_TYPE_ADJUSTMENT){
        if (!NIL_P(arg1)) adj = GTK_ADJUSTMENT(RVAL2GOBJ(arg1));
        widget = gtk_vscale_new(adj);
    } else {
        widget = gtk_vscale_new_with_range(NUM2DBL(arg1), 
                                           NUM2DBL(arg2), NUM2DBL(arg3));
    }
    RBGTK_INITIALIZE(self, widget);
    return Qnil;
}
Exemplo n.º 10
0
int main (int argc, char ** argv)
{
  GtkWidget *window;
  GtkWidget *cpu;
  GtkWidget *fixed;
  GtkWidget *scale;

  gtk_init(&argc, &argv);


  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(window), "CPU widget");
  gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
  gtk_window_set_default_size(GTK_WINDOW(window), 200, 180);
  //gtk_window_set_decorated(GTK_WINDOW(window), FALSE);


  g_signal_connect(G_OBJECT(window), "destroy", 
       G_CALLBACK(gtk_main_quit), NULL);

  fixed = gtk_fixed_new();
  gtk_container_add(GTK_CONTAINER(window), fixed);

  cpu = gtk_cpu_new();
  gtk_fixed_put(GTK_FIXED(fixed), cpu, 30, 40);


  scale = gtk_vscale_new_with_range(0.0, 100.0, 1.0);
  gtk_range_set_inverted(GTK_RANGE(scale), TRUE);
  gtk_scale_set_value_pos(GTK_SCALE(scale), GTK_POS_TOP);
  gtk_widget_set_size_request(scale, 50, 120);
  gtk_fixed_put(GTK_FIXED(fixed), scale, 130, 20);

  g_signal_connect(G_OBJECT(scale), "value_changed", G_CALLBACK(set_value), (gpointer) cpu);

  gtk_widget_show(cpu);
  gtk_widget_show(fixed);
  gtk_widget_show_all(window);
  gtk_main();

  return 0;
}
Exemplo n.º 11
0
int main(int argc, char *argv[]) {
	gtk_init(&argc, &argv);

	GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	g_signal_connect_swapped(G_OBJECT(window), "delete_event", G_CALLBACK(gtk_main_quit), G_OBJECT(window));
	gtk_widget_show(window);

	GtkWidget *vscale = gtk_vscale_new_with_range(0, 10, 1);
	// gtk_scale_set_draw_value(GTK_SCALE(vscale), FALSE);
	gtk_scale_set_digits(GTK_SCALE(vscale), 4);
	gtk_scale_set_value_pos(GTK_SCALE(vscale), GTK_POS_LEFT);
	gtk_container_add(GTK_CONTAINER(window), vscale);
	gtk_widget_show(vscale);




	gtk_main();
	return 0;
}
Exemplo n.º 12
0
static GtkWidget *
volume_create_slider(volume_priv *c)
{
    GtkWidget *slider, *win;
    GtkWidget *frame;
    
    win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size(GTK_WINDOW(win), 180, 180);
    gtk_window_set_decorated(GTK_WINDOW(win), FALSE);
    gtk_window_set_resizable(GTK_WINDOW(win), FALSE);
    gtk_container_set_border_width(GTK_CONTAINER(win), 1);
    gtk_window_set_skip_taskbar_hint(GTK_WINDOW(win), TRUE);
    gtk_window_set_skip_pager_hint(GTK_WINDOW(win), TRUE);
    gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_MOUSE);
    gtk_window_stick(GTK_WINDOW(win));

    frame = gtk_frame_new(NULL);
    gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
    gtk_container_add(GTK_CONTAINER(win), frame);
    gtk_container_set_border_width(GTK_CONTAINER(frame), 1);
    
    slider = gtk_vscale_new_with_range(0.0, 100.0, 1.0);
    gtk_widget_set_size_request(slider, 25, 82);
    gtk_scale_set_draw_value(GTK_SCALE(slider), TRUE);
    gtk_scale_set_value_pos(GTK_SCALE(slider), GTK_POS_BOTTOM);
    gtk_scale_set_digits(GTK_SCALE(slider), 0);
    gtk_range_set_inverted(GTK_RANGE(slider), TRUE);
    gtk_range_set_value(GTK_RANGE(slider), ((meter_priv *) c)->level);
    DBG("meter->level %f\n", ((meter_priv *) c)->level);
    g_signal_connect(G_OBJECT(slider), "value_changed",
        G_CALLBACK(slider_changed), c);
    g_signal_connect(G_OBJECT(slider), "enter-notify-event",
        G_CALLBACK(crossed), (gpointer)c);
    g_signal_connect(G_OBJECT(slider), "leave-notify-event",
        G_CALLBACK(crossed), (gpointer)c);
    gtk_container_add(GTK_CONTAINER(frame), slider);
    
    c->slider = slider;
    return win;
}  
Exemplo n.º 13
0
gint main (gint argc, gchar *argv[])
{
    gtk_init (&argc, &argv);
    gst_init (&argc, &argv);

    GstElement* pipeline = gst_pipeline_new ("pipeline");

    //window that contains an area where the video is drawn
    GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_widget_set_size_request (window, 640, 480);
    gtk_window_move (GTK_WINDOW (window), 300, 10);
    gtk_window_set_title (GTK_WINDOW (window), "glimagesink implement the gstxoverlay interface");
    GdkGeometry geometry;
    geometry.min_width = 1;
    geometry.min_height = 1;
    geometry.max_width = -1;
    geometry.max_height = -1;
    gtk_window_set_geometry_hints (GTK_WINDOW (window), window, &geometry, GDK_HINT_MIN_SIZE);

    //window to control the states
    GtkWidget* window_control = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    geometry.min_width = 1;
    geometry.min_height = 1;
    geometry.max_width = -1;
    geometry.max_height = -1;
    gtk_window_set_geometry_hints (GTK_WINDOW (window_control), window_control, &geometry, GDK_HINT_MIN_SIZE);
    gtk_window_set_resizable (GTK_WINDOW (window_control), FALSE);
    gtk_window_move (GTK_WINDOW (window_control), 10, 10);
    GtkWidget* table = gtk_table_new (2, 1, TRUE);
    gtk_container_add (GTK_CONTAINER (window_control), table);

    //control state null
    GtkWidget* button_state_null = gtk_button_new_with_label ("GST_STATE_NULL");
    g_signal_connect (G_OBJECT (button_state_null), "clicked",
        G_CALLBACK (button_state_null_cb), pipeline);
    gtk_table_attach_defaults (GTK_TABLE (table), button_state_null, 0, 1, 0, 1);
    gtk_widget_show (button_state_null);

    //control state ready
    GtkWidget* button_state_ready = gtk_button_new_with_label ("GST_STATE_READY");
    g_signal_connect (G_OBJECT (button_state_ready), "clicked",
        G_CALLBACK (button_state_ready_cb), pipeline);
    gtk_table_attach_defaults (GTK_TABLE (table), button_state_ready, 0, 1, 1, 2);
    gtk_widget_show (button_state_ready);

    //control state paused
    GtkWidget* button_state_paused = gtk_button_new_with_label ("GST_STATE_PAUSED");
    g_signal_connect (G_OBJECT (button_state_paused), "clicked",
        G_CALLBACK (button_state_paused_cb), pipeline);
    gtk_table_attach_defaults (GTK_TABLE (table), button_state_paused, 0, 1, 2, 3);
    gtk_widget_show (button_state_paused);

    //control state playing
    GtkWidget* button_state_playing = gtk_button_new_with_label ("GST_STATE_PLAYING");
    g_signal_connect (G_OBJECT (button_state_playing), "clicked",
        G_CALLBACK (button_state_playing_cb), pipeline);
    gtk_table_attach_defaults (GTK_TABLE (table), button_state_playing, 0, 1, 3, 4);
    gtk_widget_show (button_state_playing);

    //change framerate
    GtkWidget* slider_fps = gtk_vscale_new_with_range (1, 30, 2);
    g_signal_connect (G_OBJECT (slider_fps), "format-value",
        G_CALLBACK (slider_fps_cb), pipeline);
    gtk_table_attach_defaults (GTK_TABLE (table), slider_fps, 1, 2, 0, 4);
    gtk_widget_show (slider_fps);

    gtk_widget_show (table);
    gtk_widget_show (window_control);

    //configure the pipeline
    g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(destroy_cb), pipeline);

    GstElement* videosrc = gst_element_factory_make ("videotestsrc", "videotestsrc");
    GstElement* glupload = gst_element_factory_make ("glupload", "glupload");
    GstElement* glfiltercube = gst_element_factory_make ("glfiltercube", "glfiltercube");
    GstElement* glfilterlaplacian = gst_element_factory_make ("glfilterlaplacian", "glfilterlaplacian");
    GstElement* videosink = gst_element_factory_make ("glimagesink", "glimagesink");

    GstCaps *caps = gst_caps_new_simple("video/x-raw-yuv",
                                        "width", G_TYPE_INT, 640,
                                        "height", G_TYPE_INT, 480,
                                        "framerate", GST_TYPE_FRACTION, 25, 1,
                                        "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'),
                                        NULL) ;

    gst_bin_add_many (GST_BIN (pipeline), videosrc, glupload, glfiltercube, glfilterlaplacian, videosink, NULL);

    gboolean link_ok = gst_element_link_filtered(videosrc, glupload, caps) ;
    gst_caps_unref(caps) ;
    if(!link_ok)
    {
        g_warning("Failed to link videosrc to glupload!\n") ;
        return -1;
    }

    if(!gst_element_link_many(glupload, glfiltercube, glfilterlaplacian, videosink, NULL))
    {
        g_warning("Failed to link glupload to videosink!\n") ;
        return -1;
    }

    //area where the video is drawn
    GtkWidget* area = gtk_drawing_area_new();
    gtk_container_add (GTK_CONTAINER (window), area);

    //set window id on this event
    GstBus* bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
    gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, area);
    gst_bus_add_signal_watch (bus);
    g_signal_connect(bus, "message::error", G_CALLBACK(end_stream_cb), pipeline);
    g_signal_connect(bus, "message::warning", G_CALLBACK(end_stream_cb), pipeline);
    g_signal_connect(bus, "message::eos", G_CALLBACK(end_stream_cb), pipeline);
    gst_object_unref (bus);

    //needed when being in GST_STATE_READY, GST_STATE_PAUSED
    //or resizing/obscuring the window
    g_signal_connect(area, "expose-event", G_CALLBACK(expose_cb), videosink);

    g_signal_connect (area, "realize", G_CALLBACK (area_realize_cb), pipeline);

    //start
    GstStateChangeReturn ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
    if (ret == GST_STATE_CHANGE_FAILURE)
    {
        g_print ("Failed to start up pipeline!\n");
        return -1;
    }

    gtk_widget_show_all (window);

    gtk_main();

    return 0;
}
Exemplo n.º 14
0
static GtkWidget *create_counter(void)
{
	GtkWidget *table = gtk_table_new(2, 2, TRUE);
	GtkWidget *freq_frame = gtk_frame_new("Frequency");
	GtkWidget *range_frame = gtk_frame_new("Range");
	GtkWidget *gate_frame = gtk_frame_new("Gate");
	GtkWidget *trigger_frame = gtk_frame_new("Trigger");
	GtkWidget *box, *button, *slider;
	GSList *group;
	PangoFontDescription *font;
	
	gtk_container_set_border_width(GTK_CONTAINER(table), 5);
	
	freq_label = gtk_label_new("--- Mhz");
	range_label = gtk_label_new("-");

	font = pango_font_description_from_string("Monospace 16");
        gtk_widget_modify_font(freq_label, font);
	gtk_widget_modify_font(range_label, font);

	gtk_container_add(GTK_CONTAINER(freq_frame), freq_label);
	gtk_container_add(GTK_CONTAINER(range_frame), range_label);

	/* radio buttons */
	box = gtk_vbox_new(FALSE, 5);
	
	button = gtk_radio_button_new_with_label(NULL, "0.5 sec Gate (Period ON)");
	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
	gtk_box_pack_start(GTK_BOX(box), button, FALSE, TRUE, 0);

	g_signal_connect(G_OBJECT(button), "toggled",
	                 G_CALLBACK(radio_button_callback_1), NULL);

	button = gtk_radio_button_new_with_label(group, "0.5 sec Gate (Period OFF)");
	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
	gtk_box_pack_start(GTK_BOX(box), button, FALSE, TRUE, 0);
	
	g_signal_connect(G_OBJECT(button), "toggled",
	                 G_CALLBACK(radio_button_callback_2), NULL);
	
	button = gtk_radio_button_new_with_label(group, "5 sec Gate (Period OFF)");
	gtk_box_pack_start(GTK_BOX(box), button, FALSE, TRUE, 0);
	
	g_signal_connect(G_OBJECT(button), "toggled",
	                 G_CALLBACK(radio_button_callback_3), NULL);
	
	gtk_container_add(GTK_CONTAINER(gate_frame), box);

	/* trigger slider */
	slider = gtk_vscale_new_with_range(-31, 31, 1);
	gtk_range_set_value(GTK_RANGE(slider), 0);
	g_signal_connect(slider, "value_changed",
	                 G_CALLBACK(slider_callback), NULL);
	gtk_container_add(GTK_CONTAINER(trigger_frame), slider);

	gtk_table_attach_defaults(GTK_TABLE(table), freq_frame, 0, 1, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE(table), range_frame, 1, 2, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE(table), gate_frame, 0, 2, 1, 2);
	gtk_table_attach_defaults(GTK_TABLE(table), trigger_frame, 2, 3, 0, 2);

	gtk_table_set_row_spacings(GTK_TABLE(table), 5);
	gtk_table_set_col_spacings(GTK_TABLE(table), 5);

	return table;
}
Exemplo n.º 15
0
    //____________________________________________________
    SliderDemoWidget::SliderDemoWidget( void )
    {

        // main widget
        GtkWidget* mainWidget( gtk_hbox_new( false, 0 ) );
        gtk_box_set_spacing( GTK_BOX( mainWidget ), 5 );
        setWidget( mainWidget );

        // setup
        setName( "Sliders" );
        setComments( "Shows the appearance of sliders, progress bars and scrollbars" );
        setIconName( "measure" );
        realize();

        // horizontal sliders
        {

            // frame
            GtkWidget* frame( gtk_frame_new( "Horizontal" ) );
            gtk_box_pack_start( GTK_BOX( mainWidget ), frame, true, true, 0 );
            gtk_widget_show( frame );

            // container
            GtkWidget* box( gtk_vbox_new( false, 0 ) );
            gtk_container_set_border_width( GTK_CONTAINER( box ), 5 );
            gtk_box_set_spacing( GTK_BOX( box ), 2 );
            gtk_widget_show( box );
            gtk_container_add( GTK_CONTAINER( frame ), box );

            // scale
            _horizontalSliders._scale = gtk_hscale_new_with_range( 0, 100, 1 );
            gtk_scale_set_draw_value( GTK_SCALE( _horizontalSliders._scale ), false );
            gtk_box_pack_start( GTK_BOX( box ), _horizontalSliders._scale, false, true, 0 );
            gtk_widget_show( _horizontalSliders._scale );


            // progress entry
            _horizontalSliders._progressEntry = gtk_entry_new();
            gtk_entry_set_text( GTK_ENTRY( _horizontalSliders._progressEntry ), "Progress Bar Entry" );
            gtk_entry_set_progress_fraction( GTK_ENTRY( _horizontalSliders._progressEntry ), 0.25 );
            gtk_box_pack_start( GTK_BOX( box ), _horizontalSliders._progressEntry, false, true, 0 );
            gtk_widget_show( _horizontalSliders._progressEntry );

            // progress bar
            _horizontalSliders._progressBar = gtk_progress_bar_new();
            #if GTK_CHECK_VERSION(3, 0, 0)
            gtk_orientable_set_orientation( GTK_ORIENTABLE( _horizontalSliders._progressBar ), GTK_ORIENTATION_HORIZONTAL );
            #else
            gtk_progress_bar_set_orientation( GTK_PROGRESS_BAR( _horizontalSliders._progressBar ), GTK_PROGRESS_LEFT_TO_RIGHT );
            #endif

            gtk_progress_set_show_text( GTK_PROGRESS( _horizontalSliders._progressBar ), true );
            gtk_box_pack_start( GTK_BOX( box ), _horizontalSliders._progressBar, false, true, 0 );
            gtk_widget_show( _horizontalSliders._progressBar );

            // pulse progressBar
            _pulseProgressBar = gtk_progress_bar_new();
            #if GTK_CHECK_VERSION(3, 0, 0)
            gtk_orientable_set_orientation( GTK_ORIENTABLE( _pulseProgressBar ), GTK_ORIENTATION_HORIZONTAL );
            #else
            gtk_progress_bar_set_orientation( GTK_PROGRESS_BAR( _pulseProgressBar ), GTK_PROGRESS_LEFT_TO_RIGHT );
            #endif

            gtk_progress_bar_set_pulse_step( GTK_PROGRESS_BAR( _pulseProgressBar ), 0.01 );
            gtk_box_pack_start( GTK_BOX( box ), _pulseProgressBar, false, true, 0 );
            gtk_widget_show( _pulseProgressBar );

            // scrollbar
            GtkAdjustment* adjustment( GTK_ADJUSTMENT( gtk_adjustment_new( 25, 0, 110, 1, 1, 10 ) ) );
            _horizontalSliders._scrollBar = gtk_hscrollbar_new( adjustment );
            gtk_box_pack_start( GTK_BOX( box ), _horizontalSliders._scrollBar, false, true, 0 );
            gtk_widget_show( _horizontalSliders._scrollBar );

        }

        // vertical sliders
        {

            // frame
            GtkWidget* frame( gtk_frame_new( "Vertical" ) );
            gtk_box_pack_start( GTK_BOX( mainWidget ), frame, false, true, 0 );
            gtk_widget_show( frame );

            // container
            GtkWidget* box( gtk_hbox_new( false, 0 ) );
            gtk_container_set_border_width( GTK_CONTAINER( box ), 5 );
            gtk_box_set_spacing( GTK_BOX( box ), 5 );
            gtk_widget_show( box );
            gtk_container_add( GTK_CONTAINER( frame ), box );

            // scale
            _verticalSliders._scale = gtk_vscale_new_with_range( 0, 100, 1 );
            gtk_scale_set_draw_value( GTK_SCALE( _verticalSliders._scale ), false );
            gtk_box_pack_start( GTK_BOX( box ), _verticalSliders._scale, false, true, 0 );
            gtk_widget_show( _verticalSliders._scale );

            // progress bar
            _verticalSliders._progressBar = gtk_progress_bar_new();
            #if GTK_CHECK_VERSION(3, 0, 0)
            gtk_orientable_set_orientation( GTK_ORIENTABLE( _verticalSliders._progressBar ), GTK_ORIENTATION_VERTICAL );
            #else
            gtk_progress_bar_set_orientation( GTK_PROGRESS_BAR( _verticalSliders._progressBar ), GTK_PROGRESS_BOTTOM_TO_TOP );
            #endif

            gtk_progress_set_show_text( GTK_PROGRESS( _verticalSliders._progressBar ), true );
            gtk_box_pack_start( GTK_BOX( box ), _verticalSliders._progressBar, false, true, 0 );
            gtk_widget_show( _verticalSliders._progressBar );

            // scrollbar
            GtkAdjustment* adjustment( GTK_ADJUSTMENT( gtk_adjustment_new( 25, 0, 110, 1, 1, 10 ) ) );
            _verticalSliders._scrollBar = gtk_vscrollbar_new( adjustment );
            gtk_box_pack_start( GTK_BOX( box ), _verticalSliders._scrollBar, false, true, 0 );
            gtk_widget_show( _verticalSliders._scrollBar );

        }

        // connections
        connect( G_OBJECT( _horizontalSliders._scale ), "value-changed", GCallback( valueChanged ), this );
        connect( G_OBJECT( _horizontalSliders._scrollBar ), "value-changed", GCallback( valueChanged ), this );

        connect( G_OBJECT( _verticalSliders._scale ), "value-changed", GCallback( valueChanged ), this );
        connect( G_OBJECT( _verticalSliders._scrollBar ), "value-changed", GCallback( valueChanged ), this );

        // Initialize all
        gtk_range_set_value( GTK_RANGE( _verticalSliders._scale ), 25 );
    }
Exemplo n.º 16
0
static sequence_view_t *new_sequence_view( void *vp, int num )
{
	sequence_view_t *seqv = (sequence_view_t*) vj_calloc(sizeof(sequence_view_t));

	seqv->num = num;
	seqv->backlink = vp;

	seqv->event_box = gtk_event_box_new();
	gtk_event_box_set_visible_window( GTK_EVENT_BOX(seqv->event_box), TRUE );
	GTK_WIDGET_SET_FLAGS( seqv->event_box, GTK_CAN_FOCUS );

	g_signal_connect( G_OBJECT( seqv->event_box ),
				"button_press_event",
				G_CALLBACK( seqv_mouse_press_event ),
				(gpointer*) seqv );
	gtk_widget_show( GTK_WIDGET( seqv->event_box ) );


	gchar *track_title = g_new0( gchar, 20 );
	sprintf(track_title, "Track %d", num );
	seqv->frame = gtk_frame_new( track_title );
	g_free(track_title);
	
	gtk_container_set_border_width( GTK_CONTAINER( seqv->frame) , 1 );
	gtk_widget_show( GTK_WIDGET( seqv->frame ) );
	gtk_container_add( GTK_CONTAINER( seqv->event_box), seqv->frame );

	seqv->main_vbox = gtk_vbox_new(FALSE,0);
	gtk_container_add( GTK_CONTAINER( seqv->frame ), seqv->main_vbox );
	gtk_widget_show( GTK_WIDGET( seqv->main_vbox ) );
	
	seqv->area = gtk_image_new();

	
	gtk_box_pack_start( GTK_BOX(seqv->main_vbox),GTK_WIDGET( seqv->area), FALSE,FALSE,0);
	gtk_widget_set_size_request_( seqv->area, 176,144  ); //FIXME
	seqv->panel = gtk_frame_new(NULL);

	seqv->toggle = gtk_toggle_button_new_with_label( "preview" );
	
	if(num>0) {
		gtk_toggle_button_set_active(
			GTK_TOGGLE_BUTTON(seqv->toggle), FALSE );
		g_signal_connect( G_OBJECT( seqv->toggle ), "toggled", G_CALLBACK(sequence_preview_cb),
			(gpointer)seqv );
		gtk_box_pack_start( GTK_BOX(seqv->main_vbox), seqv->toggle,FALSE,FALSE, 0 );

		gtk_widget_set_sensitive_( GTK_WIDGET( seqv->toggle ), FALSE );
	
		gtk_widget_show( seqv->toggle );
	} else {
		gtk_box_pack_start( GTK_BOX(seqv->main_vbox), seqv->toggle,FALSE,FALSE, 0 );
		gtk_widget_show( seqv->toggle );
		gtk_widget_set_sensitive_( GTK_WIDGET( seqv->toggle ), FALSE );
	}

	GtkWidget *vvbox = gtk_vbox_new(FALSE, 0);
	seqv->button_box = gtk_hbox_new(FALSE,0);
	gtk_box_pack_start( GTK_BOX(vvbox), seqv->button_box ,FALSE,FALSE, 0 );	
	add_buttons( seqv,seqv,seqv->button_box );

	gtk_widget_show( seqv->button_box );	
	gtk_container_add( GTK_CONTAINER( seqv->main_vbox ), seqv->panel );

	seqv->button_box2 = gtk_hbox_new(FALSE, 0);
	gtk_box_pack_start( GTK_BOX(vvbox), seqv->button_box2, FALSE,FALSE, 0 );
	add_buttons2( seqv,seqv,seqv->button_box2 );
	gtk_widget_show( seqv->button_box2 );
	gtk_container_add( GTK_CONTAINER( seqv->panel ), vvbox );
	gtk_widget_show(vvbox);
	
	GtkWidget *box = gtk_vbox_new(FALSE,0);
	seqv->timeline_ = gtk_hscale_new_with_range( 0.0,1.0,0.1 );
	gtk_scale_set_draw_value( GTK_SCALE(seqv->timeline_), FALSE );
	//gtk_widget_set_size_request_( seqv->panel,180 ,180);
	gtk_adjustment_set_value(
                GTK_ADJUSTMENT(GTK_RANGE(seqv->timeline_)->adjustment), 0.0 );
	gtk_widget_show( seqv->panel );
	gtk_box_pack_start( GTK_BOX( box ), seqv->timeline_, FALSE,FALSE, 0 );
	gtk_box_pack_start( GTK_BOX( vvbox ), box , FALSE,FALSE,0);
	gtk_widget_show(seqv->timeline_);
	g_signal_connect( seqv->timeline_, "value_changed",
       	         (GCallback) sequence_set_current_frame, (gpointer*) seqv );

	GtkWidget *scroll = gtk_scrolled_window_new(NULL,NULL);
	gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW(scroll), GTK_SHADOW_ETCHED_IN );
	gtk_widget_set_size_request_(scroll,30,70);
	gtk_container_set_border_width(GTK_CONTAINER(scroll),0);
	gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(scroll),GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC );
	GtkWidget *vvvbox = gtk_hbox_new(FALSE,0);
	seqv->tracks = create_track_view(seqv->num, MAX_TRACKS, (void*) seqv );
	gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( get_track_tree(seqv->tracks)) , FALSE );
	gtk_widget_set_size_request_( get_track_tree(seqv->tracks),20,80 );
	gtk_widget_show(scroll);

	gtk_scrolled_window_add_with_viewport(
		GTK_SCROLLED_WINDOW( scroll ), get_track_tree(seqv->tracks) );
	gtk_widget_show( get_track_tree(seqv->tracks));
	gtk_box_pack_start( GTK_BOX(vvvbox), scroll, TRUE,TRUE, 0);

	GtkWidget *hhbox = gtk_hbox_new(FALSE,0);

	seqv->sliders_[0] = gtk_vscale_new_with_range( -12.0,12.0,1.0 );
	seqv->sliders_[1] = gtk_vscale_new_with_range( 0.0, 1.0, 0.01 );

	gtk_adjustment_set_value(
		GTK_ADJUSTMENT(GTK_RANGE(seqv->sliders_[0])->adjustment), 1.0 );
	gtk_adjustment_set_value(
                GTK_ADJUSTMENT(GTK_RANGE(seqv->sliders_[1])->adjustment), 0.0 );
				
	
	gtk_scale_set_digits( GTK_SCALE(seqv->sliders_[1]), 2 );
	g_signal_connect( G_OBJECT( seqv->sliders_[0] ), "value_changed", G_CALLBACK( seq_speed ),
				(gpointer*)seqv );		
	g_signal_connect( G_OBJECT( seqv->sliders_[1] ), "value_changed", G_CALLBACK( seq_opacity ),
				(gpointer*)seqv );		

	gtk_box_pack_start( GTK_BOX( hhbox ), seqv->sliders_[0], TRUE, TRUE, 0 );
	gtk_box_pack_start( GTK_BOX( hhbox ), seqv->sliders_[1], TRUE, TRUE, 0 );
	gtk_widget_show( seqv->sliders_[0] );
	gtk_widget_show( seqv->sliders_[1] );
	gtk_box_pack_start( GTK_BOX(vvvbox), hhbox, TRUE,TRUE, 0 );
	gtk_widget_show( hhbox ); 
	gtk_container_add( GTK_CONTAINER( box ), vvvbox );
	gtk_widget_show( vvvbox );
	gtk_widget_show( box );	

	
	GtkWidget *hbox = gtk_hbox_new(FALSE,0);
	gtk_box_set_spacing( GTK_BOX(hbox), 10 );
	seqv->labels_[0] = gtk_label_new( "00:00:00:00" );
	seqv->labels_[1] = gtk_label_new( "00:00:00:00" );
	gtk_box_pack_start( GTK_BOX( hbox ), seqv->labels_[0], FALSE, FALSE, 0 );
	gtk_box_pack_start( GTK_BOX( hbox ), seqv->labels_[1], FALSE, FALSE, 0 );
	gtk_widget_show( seqv->labels_[0] );
	gtk_widget_show( seqv->labels_[1] );
	gtk_box_pack_start( GTK_BOX(seqv->main_vbox), hbox, FALSE,FALSE, 0 );
	gtk_widget_show( hbox );
	

	gtk_widget_set_sensitive_(GTK_WIDGET(seqv->panel), FALSE );

	gtk_widget_show( GTK_WIDGET( seqv->area ) );

	return seqv;
}
Exemplo n.º 17
0
GtkWidget *
make_selection_view ( GjayApp *gjay ) {
    GtkWidget * vbox1, * vbox2, * hbox1, * hbox2;
    GtkWidget * alignment, * event_box, * swin, *color_button;
    GtkCellRenderer * text_renderer, * pixbuf_renderer;
    GtkTreeViewColumn *column;
	struct play_songs_data *psd;
 
    vbox1 = gtk_vbox_new (FALSE, 2);  
    
    hbox1 = gtk_hbox_new (FALSE, 2);
    gtk_box_pack_start(GTK_BOX(vbox1), hbox1, FALSE, FALSE, 2);
    icon = gtk_image_new_from_pixbuf (gjay_get_pixbuf(gjay->gui, PM_ICON_CLOSED));
    gtk_box_pack_start(GTK_BOX(hbox1), icon, FALSE, FALSE, 2);

    vbox2 = gtk_vbox_new(FALSE, 2);
    label_name = gtk_label_new("");
    label_type = gtk_label_new("");
    gtk_box_pack_start(GTK_BOX(hbox1), vbox2, FALSE, FALSE, 2);

    alignment = gtk_alignment_new (0, 0, 0, 0);
    gtk_container_add(GTK_CONTAINER(alignment), label_name);
    gtk_box_pack_start(GTK_BOX(vbox2), alignment, FALSE, FALSE, 2);

    alignment = gtk_alignment_new (0, 0, 0, 0);
    gtk_container_add(GTK_CONTAINER(alignment), label_type);
    gtk_box_pack_start(GTK_BOX(vbox2), alignment, FALSE, FALSE, 2);

    alignment = gtk_alignment_new (1, 0.5, 0, 0);
    gtk_box_pack_start(GTK_BOX(hbox1), alignment, TRUE, TRUE, 2);

    hbox2 = gtk_hbox_new (FALSE, 2);
    gtk_container_add(GTK_CONTAINER(alignment), hbox2);

    event_box = gtk_event_box_new ();
    gtk_box_pack_start(GTK_BOX(hbox2), event_box, FALSE, FALSE, 2);

    play = gtk_image_new_from_pixbuf(gjay->gui->pixbufs[PM_BUTTON_PLAY]);
    gtk_widget_set_tooltip_text(event_box,
        "Play the selected songs in the music player");
    gtk_container_add (GTK_CONTAINER(event_box), play);
    gtk_widget_set_events (event_box, GDK_BUTTON_PRESS_MASK);

	psd = g_malloc0(sizeof(struct play_songs_data));
	psd->player = gjay->player;
	psd->main_window = gjay->gui->main_window;
	psd->playlist = gjay->selected_songs;
    g_signal_connect (G_OBJECT(event_box), "button_press_event",
                      G_CALLBACK(play_selected), psd);

    event_box = gtk_event_box_new ();
    gtk_box_pack_start(GTK_BOX(hbox2), event_box, FALSE, FALSE, 2);
    
    event_box = gtk_event_box_new ();
    gtk_box_pack_start(GTK_BOX(hbox2), event_box, FALSE, FALSE, 2);
    select_all_recursive = gtk_image_new_from_pixbuf(gjay->gui->pixbufs[PM_BUTTON_ALL]);
    gtk_widget_set_tooltip_text (event_box,
        "Select all songs in this directory");
    gtk_container_add (GTK_CONTAINER(event_box), select_all_recursive);
    gtk_widget_set_events (event_box, GDK_BUTTON_PRESS_MASK);
    g_signal_connect(G_OBJECT(event_box), "button_press_event",
                     G_CALLBACK (select_all_selected), gjay);

    vbox_lower = gtk_vbox_new (FALSE, 2);
    gtk_box_pack_start(GTK_BOX(vbox1), vbox_lower, TRUE, TRUE, 2);

    list_store = gtk_list_store_new(LAST_COLUMN,
                                    G_TYPE_STRING,
                                    G_TYPE_STRING,
                                    GDK_TYPE_PIXBUF,
                                    G_TYPE_STRING);
    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
    g_object_unref (G_OBJECT (list_store));
    text_renderer = gtk_cell_renderer_text_new ();
    pixbuf_renderer = gtk_cell_renderer_pixbuf_new ();
    column = gtk_tree_view_column_new_with_attributes ("Artist", text_renderer,
                                                       "text", ARTIST_COLUMN,
                                                       NULL);
    gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
    column = gtk_tree_view_column_new_with_attributes ("Title", text_renderer,
                                                       "text", TITLE_COLUMN,
                                                       NULL);
    gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
    column = gtk_tree_view_column_new_with_attributes ("Freq", pixbuf_renderer,
                                                       "pixbuf", FREQ_COLUMN,
                                                       NULL);
    gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
    column = gtk_tree_view_column_new_with_attributes ("BPM", text_renderer,
                                                       "text", BPM_COLUMN,
                                                       NULL);
    gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
    
    swin = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
                                    GTK_POLICY_AUTOMATIC,
                                    GTK_POLICY_AUTOMATIC);
    gtk_container_add(GTK_CONTAINER(swin), tree);

    gtk_box_pack_start(GTK_BOX(vbox_lower), swin, TRUE, TRUE, 2);
    
    
    hbox2 = gtk_hbox_new (FALSE, 2);
    gtk_box_pack_start(GTK_BOX(vbox_lower), hbox2, FALSE, FALSE, 2);

    color_button = colorbutton_new(gjay);
    colorbutton_set_callback(GTK_COLOR_BUTTON(color_button),
                             G_CALLBACK(update_selected_songs_color),
                             gjay);
    gtk_box_pack_start(GTK_BOX(hbox2), color_button, FALSE, FALSE, 2);
    alignment = gtk_alignment_new (0, 1, 0.1, 0.1);
    gtk_box_pack_start(GTK_BOX(hbox2), alignment, FALSE, FALSE, 2);

    rating_vbox = gtk_vbox_new (FALSE, 2);
    gtk_box_pack_start(GTK_BOX(hbox2), rating_vbox, TRUE, FALSE, 2);    
    label_rating = gtk_label_new("Rating");
    gtk_box_pack_start(GTK_BOX(rating_vbox), label_rating, FALSE, FALSE, 2);
    
    rating = gtk_vscale_new_with_range  (MIN_RATING,
                                         MAX_RATING,
                                         0.2);
    g_signal_connect (G_OBJECT(rating), "value-changed",
                      G_CALLBACK (rating_changed), gjay);

    gtk_range_set_inverted(GTK_RANGE(rating), TRUE);
    alignment = gtk_alignment_new (0.5, 0, 
                                   0.5, 1);
    gtk_container_add(GTK_CONTAINER(alignment), rating);
    gtk_box_pack_start(GTK_BOX(rating_vbox), alignment, TRUE, TRUE, 2);

    return vbox1;
}
Exemplo n.º 18
0
static void fill_sample_table(DrMrUi* ui, int samples, char** names,GtkWidget** gain_sliders, GtkWidget** pan_sliders) {
  int row = 0;
  int col = 0;
  int si;
  gchar buf[64];
  int rows = (samples/ui->cols);
  if (samples % ui->cols != 0) rows++;
  gtk_table_resize(ui->sample_table,rows,ui->cols);

  switch (ui->startSamp) {
  case 1: // bottom left
    row = rows-1;
    break;
  case 2: // top right
    col = ui->cols-1;
    break;
  case 3: // bottom right
    row = rows-1;
    col = ui->cols-1;
    break;
  }

  for(si = 0;si<samples;si++) {
    GtkWidget *frame,*hbox,*gain_vbox,*pan_vbox;
    GtkWidget* gain_slider;
    GtkWidget* pan_slider;
    GtkWidget* gain_label;
    GtkWidget* pan_label;
    gboolean slide_expand;
    snprintf(buf,64,"<b>%s</b> (%i)",names[si],si);

    frame = gtk_frame_new(buf);
    gtk_label_set_use_markup(GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(frame))),true);
    gtk_frame_set_shadow_type(GTK_FRAME(frame),GTK_SHADOW_OUT);
    hbox = gtk_hbox_new(false,0);

#ifdef NO_NKNOB
    gain_slider = gtk_vscale_new_with_range(GAIN_MIN,6.0,1.0);
    gtk_scale_set_value_pos(GTK_SCALE(gain_slider),GTK_POS_BOTTOM);
    gtk_scale_set_digits(GTK_SCALE(gain_slider),1);
    gtk_scale_add_mark(GTK_SCALE(gain_slider),0.0,GTK_POS_RIGHT,"0 dB");
    // Hrmm, -inf label is at top in ardour for some reason
    //gtk_scale_add_mark(GTK_SCALE(gain_slider),GAIN_MIN,GTK_POS_RIGHT,"-inf");
    gtk_range_set_inverted(GTK_RANGE(gain_slider),true);
    slide_expand = true;
#else
    gain_slider = n_knob_new_with_range(0.0,GAIN_MIN,6.0,1.0);
    n_knob_set_load_prefix(N_KNOB(gain_slider),ui->bundle_path);
    gtk_widget_set_has_tooltip(gain_slider,TRUE);
    slide_expand = false;
#endif
    g_object_set_qdata (G_OBJECT(gain_slider),ui->gain_quark,GINT_TO_POINTER(si));
    if (gain_sliders) gain_sliders[si] = gain_slider;
    if (si < 32)
      gtk_range_set_value(GTK_RANGE(gain_slider),ui->gain_vals[si]);
    else // things are gross if we have > 32 samples, what to do?
      gtk_range_set_value(GTK_RANGE(gain_slider),0.0);
    g_signal_connect(G_OBJECT(gain_slider),"change-value",G_CALLBACK(gain_callback),ui);
    gain_label = gtk_label_new("Gain");
    gain_vbox = gtk_vbox_new(false,0);

#ifdef NO_NKNOB
    pan_slider = gtk_hscale_new_with_range(-1.0,1.0,0.1);
    gtk_scale_add_mark(GTK_SCALE(pan_slider),0.0,GTK_POS_TOP,NULL);
#else
    pan_slider = n_knob_new_with_range(0.0,-1.0,1.0,0.1);
    n_knob_set_load_prefix(N_KNOB(pan_slider),ui->bundle_path);
    gtk_widget_set_has_tooltip(pan_slider,TRUE);
#endif
    if (pan_sliders) pan_sliders[si] = pan_slider;
    if (si < 32)
      gtk_range_set_value(GTK_RANGE(pan_slider),ui->pan_vals[si]);
    else
      gtk_range_set_value(GTK_RANGE(pan_slider),0);
    g_object_set_qdata (G_OBJECT(pan_slider),ui->pan_quark,GINT_TO_POINTER(si));
    g_signal_connect(G_OBJECT(pan_slider),"change-value",G_CALLBACK(pan_callback),ui);
    pan_label = gtk_label_new("Pan");
    pan_vbox = gtk_vbox_new(false,0);
    
    gtk_box_pack_start(GTK_BOX(gain_vbox),gain_slider,slide_expand,slide_expand,0);
    gtk_box_pack_start(GTK_BOX(gain_vbox),gain_label,false,false,0);

    gtk_box_pack_start(GTK_BOX(pan_vbox),pan_slider,slide_expand,slide_expand,0);
    gtk_box_pack_start(GTK_BOX(pan_vbox),pan_label,false,false,0);

    gtk_box_pack_start(GTK_BOX(hbox),gain_vbox,true,true,0);
    gtk_box_pack_start(GTK_BOX(hbox),pan_vbox,true,true,0);

    gtk_container_add(GTK_CONTAINER(frame),hbox);

    gtk_table_attach_defaults(ui->sample_table,frame,col,col+1,row,row+1);

    if (ui->startSamp > 1) {
      col--;
      if (col < 0) {
	if (ui->startSamp == 2)
	  row++;
	else
	  row--;
	col = ui->cols-1;
      }
    }
    else {
      col++;
      if (col >= ui->cols) {
	if (ui->startSamp == 0)
	  row++;
	else
	  row--;
	col = 0;
      }
    }
  }
  gtk_widget_queue_resize(GTK_WIDGET(ui->sample_table));
}
Exemplo n.º 19
0
NedMidiRecordConfigDialog::NedMidiRecordConfigDialog(GtkWindow *parent, int num, int denom, int midi_pgm,
                        int tempo_inverse, int volume, bool triplet, bool f_piano, bool dnt_split, int keysig) :
m_num(num), m_denom(denom), m_pgm(midi_pgm), m_tempo_inverse(tempo_inverse), m_metro_volume(volume), m_triplet(triplet), m_f_piano(f_piano), m_dnt_split(dnt_split), m_keysig(keysig) {
	int i;
	GtkWidget *dialog;
	GtkWidget *time_signature_frame;
	GtkWidget *numerator_label;
	GtkWidget *denominator_label;
	GtkWidget *time_signature_vbox;
	GtkWidget *time_signature_upper_hbox;
	GtkWidget *time_signature_lower_hbox;
	GtkWidget *right_vbox;
	GtkWidget *instrument_scroll;
	GtkWidget *upper_hbox;
	GtkListStore *instrumend_list_store;
	GtkTreeIter iter;
	GtkCellRenderer *instrument_renderer;
	GtkTreeViewColumn *instrument_column;
	GtkTreeViewColumn *instrument_num_column;
	GtkTreePath* instrument_tree_path;
	GtkWidget *tempo_frame;
	GtkWidget *key_frame;
	GtkWidget *key_frame_left_vbox;
	GtkWidget *key_frame_right_vbox;
	GtkWidget *radio_hbox;
	GtkWidget *main_vbox;
	GtkWidget *metro_volume_frame;
	char Str[128];

	dialog = gtk_dialog_new_with_buttons(_("Config Record"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
		GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);

	g_signal_connect(dialog, "response", G_CALLBACK (OnClose), (void *) this);

	time_signature_frame = gtk_frame_new(_("time signature"));
	time_signature_vbox = gtk_vbox_new(FALSE, 5);
	time_signature_upper_hbox = gtk_hbox_new(FALSE, 5);
	time_signature_lower_hbox = gtk_hbox_new(FALSE, 5);
	numerator_label = gtk_label_new(_("Numerator:"));
	denominator_label = gtk_label_new(_("Denominator:"));
	m_numerator = gtk_spin_button_new_with_range (1.0, 20.0, 1.0);
	gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_numerator), m_num);
	m_denominator = gtk_combo_box_new_text();
	gtk_combo_box_append_text(GTK_COMBO_BOX(m_denominator), "2");
	gtk_combo_box_append_text(GTK_COMBO_BOX(m_denominator), "4");
	gtk_combo_box_append_text(GTK_COMBO_BOX(m_denominator), "8");
	gtk_combo_box_append_text(GTK_COMBO_BOX(m_denominator), "16");
	if (m_denom < 4) {
		gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 0);
	}
	else if (m_denom < 8) {
		gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 1);
	}
	else if (m_denom < 16) {
		gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 2);
	}
	else {
		gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 3);
	}
	gtk_box_pack_start (GTK_BOX (time_signature_upper_hbox), numerator_label, FALSE, FALSE, 0);
	gtk_box_pack_end (GTK_BOX (time_signature_upper_hbox), m_numerator, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (time_signature_lower_hbox), denominator_label, FALSE, FALSE, 0);
	gtk_box_pack_end (GTK_BOX (time_signature_lower_hbox), m_denominator, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (time_signature_vbox), time_signature_upper_hbox, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (time_signature_vbox), time_signature_lower_hbox, FALSE, FALSE, 0);
	gtk_container_add (GTK_CONTAINER(time_signature_frame), time_signature_vbox);

	m_with_triplet_button = gtk_toggle_button_new_with_label(_("triplet recognition"));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_with_triplet_button), m_triplet);
	m_force_piano_button = gtk_toggle_button_new_with_label(_("force piano"));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_force_piano_button), m_f_piano);
	m_dont_split_button = gtk_toggle_button_new_with_label(_("don't split tracks"));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_dont_split_button), m_dnt_split);
	if (m_dnt_split) {
		gtk_widget_set_sensitive(m_force_piano_button, FALSE);
	}
	else if (m_f_piano) {
		gtk_widget_set_sensitive(m_dont_split_button, FALSE);
	}
	g_signal_connect(m_force_piano_button, "toggled", G_CALLBACK (OnPianoForcePressed), (void *) this);
	g_signal_connect(m_dont_split_button, "toggled", G_CALLBACK (OnDontSplitPressed), (void *) this);

	right_vbox = gtk_vbox_new(FALSE, 5);
	gtk_box_pack_start (GTK_BOX(right_vbox), time_signature_frame, FALSE, FALSE, 0);

	gtk_box_pack_start (GTK_BOX(right_vbox), m_with_triplet_button, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX(right_vbox), m_force_piano_button, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX(right_vbox), m_dont_split_button, FALSE, FALSE, 0);

	instrumend_list_store = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_STRING);

	for (i = 0; i < NedResource::getNumInstruments(); i++) {
		gtk_list_store_append (instrumend_list_store, &iter);
		gtk_list_store_set (instrumend_list_store, &iter, 0, i, 1, gettext(NedResource::GM_Instruments[i]), -1);
	}
	m_instrument_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(instrumend_list_store));
	instrument_renderer = gtk_cell_renderer_text_new ();
	instrument_num_column = gtk_tree_view_column_new_with_attributes (_("no"), instrument_renderer, "text", 0, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (m_instrument_list), instrument_num_column);
	instrument_column = gtk_tree_view_column_new_with_attributes (_("instruments"), instrument_renderer, "text", 1, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (m_instrument_list), instrument_column);
	m_instrument_adjustment = gtk_adjustment_new (0.0, 0.0, NedResource::getNumInstruments(), 1.0,  10.0, 10.0);
	instrument_scroll = gtk_vscrollbar_new(GTK_ADJUSTMENT(m_instrument_adjustment));
	gtk_tree_view_set_vadjustment (GTK_TREE_VIEW (m_instrument_list), GTK_ADJUSTMENT(m_instrument_adjustment));
	gtk_widget_set_size_request(m_instrument_list, INSTRUMENTS_WIDGET_WIDTH, MIDI_RECORD_CONFIG_SHOW_WINDOW_HEIGHT);
	sprintf(Str, "%d", m_pgm);
	instrument_tree_path = gtk_tree_path_new_from_string(Str);
	gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW (m_instrument_list), instrument_tree_path, NULL, FALSE, 0.0, 0.0);
	gtk_tree_view_set_cursor(GTK_TREE_VIEW (m_instrument_list), instrument_tree_path, NULL, FALSE);
	g_signal_connect(dialog, "scroll-event", G_CALLBACK (OnScroll), (void *) this);

	tempo_frame = gtk_frame_new(_("tempo"));
	m_tempo_scale = gtk_vscale_new_with_range(0.1 * 60.0, 2.4 * 60.0, 0.4 * 60.0);
	gtk_range_set_inverted(GTK_RANGE(m_tempo_scale), TRUE);
	gtk_range_set_value(GTK_RANGE(m_tempo_scale), 60.0 * (double) m_tempo_inverse / 100000.0);
	gtk_container_add (GTK_CONTAINER(tempo_frame), m_tempo_scale);

	metro_volume_frame = gtk_frame_new(_("volume"));
	m_metro_volume_scale = gtk_vscale_new_with_range(0.0, 127.0, 1.0);
	gtk_range_set_inverted(GTK_RANGE(m_metro_volume_scale), TRUE);
	gtk_range_set_value(GTK_RANGE(m_metro_volume_scale), m_metro_volume);
	gtk_container_add (GTK_CONTAINER(metro_volume_frame), m_metro_volume_scale);


	key_frame = gtk_frame_new(_("key"));
	radio_hbox = gtk_hbox_new(FALSE, 2);
	key_frame_left_vbox = gtk_vbox_new(FALSE, 2);
	key_frame_right_vbox = gtk_vbox_new(FALSE, 2);
	m_sig_radio_buttons[0] =  gtk_radio_button_new_with_label (NULL, gettext(NedStaffContextDialog::m_keyTab[0]));
	gtk_box_pack_start (GTK_BOX (key_frame_left_vbox),  m_sig_radio_buttons[0], FALSE, FALSE, 0);
	for (i = -5; i < 7; i++) {
		m_sig_radio_buttons[i+6] = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (m_sig_radio_buttons[0]), gettext(NedStaffContextDialog::m_keyTab[i+6]));
		if (i < 0) {
			gtk_box_pack_start (GTK_BOX (key_frame_left_vbox), m_sig_radio_buttons[i+6], FALSE, FALSE, 0);
		}
		else {
			gtk_box_pack_start (GTK_BOX (key_frame_right_vbox), m_sig_radio_buttons[i+6], FALSE, FALSE, 0);
		}
	}
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (m_sig_radio_buttons[keysig+6]), TRUE);
	gtk_box_pack_start (GTK_BOX (radio_hbox), key_frame_left_vbox,  FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (radio_hbox), key_frame_right_vbox,  FALSE, FALSE, 0);
	gtk_container_add (GTK_CONTAINER(key_frame), radio_hbox);

	upper_hbox = gtk_hbox_new(FALSE, 5);

	gtk_box_pack_start (GTK_BOX(upper_hbox), m_instrument_list, TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX(upper_hbox), instrument_scroll, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX(upper_hbox), right_vbox, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX(upper_hbox), tempo_frame, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX(upper_hbox), metro_volume_frame, FALSE, FALSE, 0);

	main_vbox = gtk_vbox_new(FALSE, 5);
	gtk_box_pack_start (GTK_BOX(main_vbox), upper_hbox, TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX(main_vbox), key_frame, FALSE, FALSE, 0);

	gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), main_vbox);
	gtk_widget_show_all (dialog);
	gtk_dialog_run(GTK_DIALOG(dialog));

}
Exemplo n.º 20
0
int
main (int argc, char *argv[])
{
  GstElement *bin;
  GstElement *src, *capsfilter, *equalizer, *spectrum, *audioconvert, *sink;
  GstCaps *caps;
  GstBus *bus;
  GtkWidget *appwindow, *vbox, *hbox, *widget;
  int i;

  gst_init (&argc, &argv);
  gtk_init (&argc, &argv);

  bin = gst_pipeline_new ("bin");

  /* White noise */
  src = gst_element_factory_make ("audiotestsrc", "src");
  g_object_set (G_OBJECT (src), "wave", 5, "volume", 0.8, NULL);

  /* Force float32 samples */
  capsfilter = gst_element_factory_make ("capsfilter", "capsfilter");
  caps =
      gst_caps_new_simple ("audio/x-raw-float", "width", G_TYPE_INT, 32, NULL);
  g_object_set (capsfilter, "caps", caps, NULL);

  equalizer = gst_element_factory_make ("equalizer-nbands", "equalizer");
  g_object_set (G_OBJECT (equalizer), "num-bands", NBANDS, NULL);

  spectrum = gst_element_factory_make ("spectrum", "spectrum");
  g_object_set (G_OBJECT (spectrum), "bands", spect_bands, "threshold", -80,
      "message", TRUE, "interval", 500 * GST_MSECOND, NULL);

  audioconvert = gst_element_factory_make ("audioconvert", "audioconvert");

  sink = gst_element_factory_make ("autoaudiosink", "sink");

  gst_bin_add_many (GST_BIN (bin), src, capsfilter, equalizer, spectrum,
      audioconvert, sink, NULL);
  if (!gst_element_link_many (src, capsfilter, equalizer, spectrum,
          audioconvert, sink, NULL)) {
    fprintf (stderr, "can't link elements\n");
    exit (1);
  }

  bus = gst_element_get_bus (bin);
  gst_bus_add_watch (bus, message_handler, NULL);
  gst_object_unref (bus);

  appwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (G_OBJECT (appwindow), "destroy",
      G_CALLBACK (on_window_destroy), NULL);
  vbox = gtk_vbox_new (FALSE, 6);

  drawingarea = gtk_drawing_area_new ();
  gtk_widget_set_size_request (drawingarea, spect_bands, spect_height);
  g_signal_connect (G_OBJECT (drawingarea), "configure-event",
      G_CALLBACK (on_configure_event), (gpointer) spectrum);
  gtk_box_pack_start (GTK_BOX (vbox), drawingarea, TRUE, TRUE, 0);

  hbox = gtk_hbox_new (FALSE, 20);

  for (i = 0; i < NBANDS; i++) {
    GstObject *band;
    gdouble freq;
    gdouble bw;
    gdouble gain;
    gchar *label;
    GtkWidget *frame, *scales_hbox;

    band = gst_child_proxy_get_child_by_index (GST_CHILD_PROXY (equalizer), i);
    g_assert (band != NULL);
    g_object_get (G_OBJECT (band), "freq", &freq, NULL);
    g_object_get (G_OBJECT (band), "bandwidth", &bw, NULL);
    g_object_get (G_OBJECT (band), "gain", &gain, NULL);

    label = g_strdup_printf ("%d Hz", (int) (freq + 0.5));
    frame = gtk_frame_new (label);
    g_free (label);

    scales_hbox = gtk_hbox_new (FALSE, 6);

    widget = gtk_vscale_new_with_range (-24.0, 12.0, 0.5);
    gtk_scale_set_draw_value (GTK_SCALE (widget), TRUE);
    gtk_scale_set_value_pos (GTK_SCALE (widget), GTK_POS_TOP);
    gtk_range_set_value (GTK_RANGE (widget), gain);
    gtk_widget_set_size_request (widget, 25, 150);
    g_signal_connect (G_OBJECT (widget), "value-changed",
        G_CALLBACK (on_gain_changed), (gpointer) band);
    gtk_box_pack_start (GTK_BOX (scales_hbox), widget, FALSE, FALSE, 0);

    widget = gtk_vscale_new_with_range (0.0, 20000.0, 5.0);
    gtk_scale_set_draw_value (GTK_SCALE (widget), TRUE);
    gtk_scale_set_value_pos (GTK_SCALE (widget), GTK_POS_TOP);
    gtk_range_set_value (GTK_RANGE (widget), bw);
    gtk_widget_set_size_request (widget, 25, 150);
    g_signal_connect (G_OBJECT (widget), "value-changed",
        G_CALLBACK (on_bandwidth_changed), (gpointer) band);
    gtk_box_pack_start (GTK_BOX (scales_hbox), widget, TRUE, TRUE, 0);

    widget = gtk_vscale_new_with_range (20.0, 20000.0, 5.0);
    gtk_scale_set_draw_value (GTK_SCALE (widget), TRUE);
    gtk_scale_set_value_pos (GTK_SCALE (widget), GTK_POS_TOP);
    gtk_range_set_value (GTK_RANGE (widget), freq);
    gtk_widget_set_size_request (widget, 25, 150);
    g_signal_connect (G_OBJECT (widget), "value-changed",
        G_CALLBACK (on_freq_changed), (gpointer) band);
    gtk_box_pack_start (GTK_BOX (scales_hbox), widget, TRUE, TRUE, 0);

    gtk_container_add (GTK_CONTAINER (frame), scales_hbox);

    gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
  }

  gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);

  gtk_container_add (GTK_CONTAINER (appwindow), vbox);
  gtk_widget_show_all (appwindow);

  gst_element_set_state (bin, GST_STATE_PLAYING);
  gtk_main ();
  gst_element_set_state (bin, GST_STATE_NULL);

  gst_object_unref (bin);

  return 0;
}
Exemplo n.º 21
0
int
gtkui_run_dialog (GtkWidget *parentwin, ddb_dialog_t *conf, uint32_t buttons, int (*callback)(int button, void *ctx), void *ctx) {
    if (!parentwin) {
        parentwin = mainwin;
    }
    // create window
    char title[200];
    snprintf (title, sizeof (title), _("Configure %s"), conf->title);
    GtkWidget *win;
    if (!buttons) {
        win = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parentwin), GTK_DIALOG_MODAL, GTK_STOCK_APPLY, GTK_RESPONSE_APPLY, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
        gtk_dialog_set_default_response (GTK_DIALOG (win), GTK_RESPONSE_OK);
    }
    else {
        win = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parentwin), GTK_DIALOG_MODAL, NULL);
        if (buttons & (1<<ddb_button_ok)) {
            gtk_dialog_add_button (GTK_DIALOG (win), GTK_STOCK_OK, GTK_RESPONSE_OK);
        }
        if (buttons & (1<<ddb_button_cancel)) {
            gtk_dialog_add_button (GTK_DIALOG (win), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
        }
        if (buttons & (1<<ddb_button_close)) {
            gtk_dialog_add_button (GTK_DIALOG (win), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
        }
        if (buttons & (1<<ddb_button_apply)) {
            gtk_dialog_add_button (GTK_DIALOG (win), GTK_STOCK_APPLY, GTK_RESPONSE_APPLY);
        }
        if (buttons & (1<<ddb_button_yes)) {
            gtk_dialog_add_button (GTK_DIALOG (win), GTK_STOCK_YES, GTK_RESPONSE_YES);
        }
        if (buttons & (1<<ddb_button_no)) {
            gtk_dialog_add_button (GTK_DIALOG (win), GTK_STOCK_NO, GTK_RESPONSE_NO);
        }
    }
    gtk_window_set_type_hint (GTK_WINDOW (win), GDK_WINDOW_TYPE_HINT_DIALOG);
    gtk_container_set_border_width (GTK_CONTAINER(win), 12);

    gtk_window_set_title (GTK_WINDOW (win), title);
    gtk_window_set_modal (GTK_WINDOW (win), TRUE);
    gtk_window_set_transient_for (GTK_WINDOW (win), GTK_WINDOW (parentwin));

    GtkWidget *widgets[100] = {NULL};
    int pack[100] = {0};
    int ncurr = 0;

    widgets[ncurr] = gtk_dialog_get_content_area (GTK_DIALOG (win));
    gtk_box_set_spacing (GTK_BOX (widgets[ncurr]), 8);
    GtkWidget *action_area = gtk_dialog_get_action_area (GTK_DIALOG (win));
    gtk_widget_show (action_area);
    gtk_button_box_set_layout (GTK_BUTTON_BOX (action_area), GTK_BUTTONBOX_END);


    // parse script
    char token[MAX_TOKEN];
    const char *script = conf->layout;
    parser_line = 1;
    while (script = gettoken (script, token)) {
        if (strcmp (token, "property")) {
            fprintf (stderr, "invalid token while loading plugin %s config dialog: %s at line %d\n", conf->title, token, parser_line);
            break;
        }
        char labeltext[MAX_TOKEN];
        script = gettoken_warn_eof (script, labeltext);
        if (!script) {
            break;
        }

        if (ncurr > 0) {
            pack[ncurr]--;
            if (pack[ncurr] < 0) {
                ncurr--;
            }
        }

        char type[MAX_TOKEN];
        script = gettoken_warn_eof (script, type);
        if (!script) {
            break;
        }

        if (!strncmp (type, "hbox[", 5) || !strncmp (type, "vbox[", 5)) {
            ncurr++;
            int n = 0;
            if (1 != sscanf (type+4, "[%d]", &n)) {
                break;
            }
            pack[ncurr] = n;

            int vert = 0;
            int hmg = FALSE;
            int fill = FALSE;
            int expand = FALSE;
            int border = 0;
            int spacing = 8;
            int height = 100;

            char param[MAX_TOKEN];
            for (;;) {
                script = gettoken_warn_eof (script, param);
                if (!script) {
                    break;
                }
                if (!strcmp (param, ";")) {
                    break;
                }
                else if (!strcmp (param, "hmg")) {
                    hmg = TRUE;
                }
                else if (!strcmp (param, "fill")) {
                    fill = TRUE;
                }
                else if (!strcmp (param, "expand")) {
                    expand = TRUE;
                }
                else if (!strncmp (param, "border=", 7)) {
                    border = atoi (param+7);
                }
                else if (!strncmp (param, "spacing=", 8)) {
                    spacing = atoi (param+8);
                }
                else if (!strncmp (param, "height=", 7)) {
                    height = atoi (param+7);
                }
            }

            widgets[ncurr] = vert ? gtk_vbox_new (TRUE, spacing) : gtk_hbox_new (TRUE, spacing);
            gtk_widget_set_size_request (widgets[ncurr], -1, height);
            gtk_widget_show (widgets[ncurr]);
            gtk_box_pack_start (GTK_BOX(widgets[ncurr-1]), widgets[ncurr], fill, expand, border);
            continue;
        }

        int vertical = 0;

        char key[MAX_TOKEN];
        for (;;) {
            script = gettoken_warn_eof (script, key);
            if (!script) {
                break;
            }
            if (!strcmp (key, "vert")) {
                vertical = 1;
            }
            else {
                break;
            }
        }

        char def[MAX_TOKEN];
        script = gettoken_warn_eof (script, def);
        if (!script) {
            break;
        }

        // add to dialog
        GtkWidget *label = NULL;
        GtkWidget *prop = NULL;
        GtkWidget *cont = NULL;
        char value[1000];
        conf->get_param (key, value, sizeof (value), def);
        if (!strcmp (type, "entry") || !strcmp (type, "password")) {
            label = gtk_label_new (_(labeltext));
            gtk_widget_show (label);
            prop = gtk_entry_new ();
            gtk_entry_set_activates_default (GTK_ENTRY (prop), TRUE);
            g_signal_connect (G_OBJECT (prop), "changed", G_CALLBACK (prop_changed), win);
            gtk_widget_show (prop);
            gtk_entry_set_text (GTK_ENTRY (prop), value);

            if (!strcmp (type, "password")) {
                gtk_entry_set_visibility (GTK_ENTRY (prop), FALSE);
            }
        }
        else if (!strcmp (type, "checkbox")) {
            prop = gtk_check_button_new_with_label (_(labeltext));
            g_signal_connect (G_OBJECT (prop), "toggled", G_CALLBACK (prop_changed), win);
            gtk_widget_show (prop);
            int val = atoi (value);
            gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prop), val);
        }
        else if (!strcmp (type, "file")) {
            label = gtk_label_new (_(labeltext));
            gtk_widget_show (label);
            if (deadbeef->conf_get_int ("gtkui.pluginconf.use_filechooser_button", 0)) {
                prop = gtk_file_chooser_button_new (_(labeltext), GTK_FILE_CHOOSER_ACTION_OPEN);
                gtk_widget_show (prop);
                gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (prop), value);
                g_signal_connect (G_OBJECT (prop), "file-set", G_CALLBACK (prop_changed), win);
            }
            else {
                cont = gtk_hbox_new (FALSE, 2);
                gtk_widget_show (cont);
                prop = gtk_entry_new ();
                gtk_entry_set_activates_default (GTK_ENTRY (prop), TRUE);
                g_signal_connect (G_OBJECT (prop), "changed", G_CALLBACK (prop_changed), win);
                gtk_widget_show (prop);
                gtk_editable_set_editable (GTK_EDITABLE (prop), FALSE);
                gtk_entry_set_text (GTK_ENTRY (prop), value);
                gtk_box_pack_start (GTK_BOX (cont), prop, TRUE, TRUE, 0);
                GtkWidget *btn = gtk_button_new_with_label ("…");
                gtk_widget_show (btn);
                gtk_box_pack_start (GTK_BOX (cont), btn, FALSE, FALSE, 0);
                g_signal_connect (G_OBJECT (btn), "clicked", G_CALLBACK (on_prop_browse_file), prop);
            }
        }
        else if (!strncmp (type, "select[", 7)) {
            int n;
            if (1 != sscanf (type+6, "[%d]", &n)) {
                break;
            }

            label = gtk_label_new (_(labeltext));
            gtk_widget_show (label);

            prop = gtk_combo_box_text_new ();
            gtk_widget_show (prop);

            for (int i = 0; i < n; i++) {
                char entry[MAX_TOKEN];
                script = gettoken_warn_eof (script, entry);
                if (!script) {
                    break;
                }

                gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (prop), entry);
            }
            if (!script) {
                break;
            }
            gtk_combo_box_set_active (GTK_COMBO_BOX (prop), atoi (value));
            g_signal_connect ((gpointer) prop, "changed",
                    G_CALLBACK (prop_changed),
                    win);
        }
        else if (!strncmp (type, "hscale[", 7) || !strncmp (type, "vscale[", 7) || !strncmp (type, "spinbtn[", 8)) {
            float min, max, step;
            const char *args;
            if (type[0] == 's') {
                args = type + 7;
            }
            else {
                args = type + 6;
            }
            if (3 != sscanf (args, "[%f,%f,%f]", &min, &max, &step)) {
                break;
            }
            int invert = 0;
            if (min >= max) {
                float tmp = min;
                min = max;
                max = tmp;
                invert = 1;
            }
            if (step <= 0) {
                step = 1;
            }
            if (type[0] == 's') {
                prop = gtk_spin_button_new_with_range (min, max, step);
                gtk_spin_button_set_value (GTK_SPIN_BUTTON (prop), atof (value));
            }
            else {
                prop = type[0] == 'h' ? gtk_hscale_new_with_range (min, max, step) : gtk_vscale_new_with_range (min, max, step);
                if (invert) {
                    gtk_range_set_inverted (GTK_RANGE (prop), TRUE);
                }
                gtk_range_set_value (GTK_RANGE (prop), (gdouble)atof (value));
                gtk_scale_set_value_pos (GTK_SCALE (prop), GTK_POS_RIGHT);
            }
            label = gtk_label_new (_(labeltext));
            gtk_widget_show (label);
            g_signal_connect (G_OBJECT (prop), "value-changed", G_CALLBACK (prop_changed), win);
            gtk_widget_show (prop);
        }

        script = gettoken_warn_eof (script, token);
        if (!script) {
            break;
        }
        if (strcmp (token, ";")) {
            fprintf (stderr, "expected `;' while loading plugin %s config dialog: %s at line %d\n", conf->title, token, parser_line);
            break;
        }


        if (label && prop) {
            GtkWidget *hbox = NULL;
            hbox = vertical ? gtk_vbox_new (FALSE, 8) : gtk_hbox_new (FALSE, 8);
            gtk_widget_show (hbox);
            gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
            gtk_box_pack_start (GTK_BOX (hbox), cont ? cont : prop, TRUE, TRUE, 0);
            cont = hbox;
        }
        else {
            cont = prop;
        }
        if (prop) {
            g_object_set_data (G_OBJECT (win), key, prop);
        }
        if (cont) {
            gtk_box_pack_start (GTK_BOX (widgets[ncurr]), cont, FALSE, FALSE, 0);
        }
    }

    int response;
    do {
        gtk_dialog_set_response_sensitive (GTK_DIALOG (win), GTK_RESPONSE_APPLY, FALSE);
        response = gtk_dialog_run (GTK_DIALOG (win));
        if (response == GTK_RESPONSE_APPLY || response == GTK_RESPONSE_OK) {
            apply_conf (win, conf);
        }
        if (callback) {
            int btn = ddb_button_from_gtk_response (response);
            if (!callback (btn, ctx)) {
                break;
            }
        }
    } while (response == GTK_RESPONSE_APPLY);
    gtk_widget_destroy (win);
    int btn = ddb_button_from_gtk_response (response);
    return btn;
}