Пример #1
0
GtkWidget* CreateScale(const char* opt_name, int opt_default = 0)
{
#if GTK_MAJOR_VERSION < 3
	GtkWidget* scale = gtk_hscale_new_with_range(0, 200, 10);
#else
	GtkWidget* scale = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0, 200, 10);
#endif

	gtk_scale_set_value_pos(GTK_SCALE(scale), GTK_POS_RIGHT);
	gtk_range_set_value(GTK_RANGE(scale), theApp.GetConfig(opt_name, opt_default));

	g_signal_connect(scale, "value-changed", G_CALLBACK(CB_RangeChanged), const_cast<char*>(opt_name));

	return scale;
}
GtkWidget *mixer_build_widget (gboolean bHorizontal)
{
	g_return_val_if_fail (myData.pControledElement != NULL, NULL);
	GtkWidget *pScale = gtk_scale_new_with_range (bHorizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, 0., 100., .5*myConfig.iScrollVariation);
	if (! bHorizontal)
		gtk_range_set_inverted (GTK_RANGE (pScale), TRUE);  // de bas en haut.
	
	myData.iCurrentVolume = cd_get_volume ();
	gtk_range_set_value (GTK_RANGE (pScale), myData.iCurrentVolume);
	
	g_signal_connect (G_OBJECT (pScale),
		"value-changed",
		G_CALLBACK (on_change_volume),
		NULL);
	
	gldi_dialog_set_widget_text_color (pScale);
	return pScale;
}
Пример #3
0
GtkWidget *
do_offscreen_window (GtkWidget *do_widget)
{
  if (!window)
    {
      GtkWidget *bin, *vbox, *scale, *button;

      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      gtk_window_set_screen (GTK_WINDOW (window),
                             gtk_widget_get_screen (do_widget));
      gtk_window_set_title (GTK_WINDOW (window), "Rotated widget");

      g_signal_connect (window, "destroy",
                        G_CALLBACK (gtk_widget_destroyed), &window);

      gtk_container_set_border_width (GTK_CONTAINER (window), 10);

      vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
      scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
                                        0, G_PI/2, 0.01);
      gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);

      button = gtk_button_new_with_label ("A Button");
      bin = gtk_rotated_bin_new ();

      g_signal_connect (scale, "value-changed", G_CALLBACK (scale_changed), bin);

      gtk_container_add (GTK_CONTAINER (window), vbox);
      gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
      gtk_box_pack_start (GTK_BOX (vbox), bin, TRUE, TRUE, 0);
      gtk_container_add (GTK_CONTAINER (bin), button);
    }

  if (!gtk_widget_get_visible (window))
    gtk_widget_show_all (window);
  else
    {
      gtk_widget_destroy (window);
      window = NULL;
    }

  return window;
}
Пример #4
0
static int
slider_setup(struct gtk_common_data *data,
    const struct sol_flow_node_options *options)
{
    int min = 0;
    int max = 100;
    int step = 1;

    struct gtk_common_data *mdata = (struct gtk_common_data *)data;
    const struct sol_flow_node_type_gtk_slider_options *opts =
        (const struct sol_flow_node_type_gtk_slider_options *)options;

    SOL_FLOW_NODE_OPTIONS_SUB_API_CHECK(options,
        SOL_FLOW_NODE_TYPE_GTK_SLIDER_OPTIONS_API_VERSION,
        -EINVAL);

    min = opts->range.min;
    max = opts->range.max;
    step = opts->range.step;

    if (min > max) {
        SOL_WRN("invalid range min=%d max=%d for slider id=%s\n",
            min, max, sol_flow_node_get_id(mdata->node));
        return -EINVAL;
    }

    if (step <= 0) {
        SOL_WRN("invalid step=%d for slider id=%s\n",
            step, sol_flow_node_get_id(mdata->node));
        return -EINVAL;
    }

    mdata->widget = gtk_scale_new_with_range
            (GTK_ORIENTATION_HORIZONTAL, min, max, step);
    g_signal_connect(mdata->widget, "value-changed",
        G_CALLBACK(on_slider_changed), mdata);
    g_object_set(mdata->widget, "hexpand", true, NULL);

    // GtkScale natural size is too small, give it a better default.
    gtk_widget_set_size_request(mdata->widget, 300, -1);

    return 0;
}
Пример #5
0
static void create_volume_scale(void)
{
    // Create a popup window
    window = gtk_window_new(GTK_WINDOW_POPUP);
    gtk_window_set_decorated(GTK_WINDOW(window), FALSE);
    gtk_window_set_skip_pager_hint(GTK_WINDOW(window), TRUE);
    gtk_window_set_skip_taskbar_hint(GTK_WINDOW(window), TRUE);
    gtk_window_set_keep_above(GTK_WINDOW(window), TRUE);
    gtk_window_set_default_size(GTK_WINDOW(window), 0, 120);

    // Create the scale and add it to the window
    scale = gtk_scale_new_with_range(GTK_ORIENTATION_VERTICAL, 0.0, 100.0, 1.0);
    gtk_scale_set_draw_value(GTK_SCALE(scale), FALSE);
    gtk_range_set_inverted(GTK_RANGE(scale), TRUE);
    gtk_container_add(GTK_CONTAINER(window), scale);
    gtk_widget_show(scale);

    // Connect the value changed signal
    g_signal_connect(G_OBJECT(scale), "value-changed", G_CALLBACK(on_scale_value_change), NULL);
}
Пример #6
0
static gboolean _task_warning (CDClockTask *pTask, const gchar *cMessage)
{
	cd_debug ("%s (%s)", __func__, cMessage);
	GldiModuleInstance *myApplet = pTask->pApplet;

	GtkWidget *pScale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 1, 60, 1);  // 1mn-60mn et 1 cran/mn.
	gtk_scale_set_digits (GTK_SCALE (pScale), 0);
	gtk_range_set_value (GTK_RANGE (pScale), pTask->iWarningDelay != 0 ? pTask->iWarningDelay : 15);  // 15mn par defaut.
	g_object_set (pScale, "width-request", CAIRO_DIALOG_MIN_SCALE_WIDTH, NULL);

	GtkWidget *pExtendedWidget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	GtkWidget *label = gtk_label_new (D_("1mn"));
	GtkWidget *pAlign = gtk_alignment_new (1., 1., 0., 0.);
	gtk_container_add (GTK_CONTAINER (pAlign), label);
	gtk_box_pack_start (GTK_BOX (pExtendedWidget), pAlign, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (pExtendedWidget), pScale, FALSE, FALSE, 0);
	label = gtk_label_new (D_("1h"));
	pAlign = gtk_alignment_new (1., 1., 0., 0.);
	gtk_container_add (GTK_CONTAINER (pAlign), label);
	gtk_box_pack_start (GTK_BOX (pExtendedWidget), pAlign, FALSE, FALSE, 0);
	
	gldi_object_unref (GLDI_OBJECT(pTask->pWarningDialog));
	
	CairoDialogAttr attr;
	memset (&attr, 0, sizeof (CairoDialogAttr));
	attr.cText = (gchar *)cMessage;
	attr.bUseMarkup = TRUE;
	attr.cImageFilePath = (gchar *)MY_APPLET_SHARE_DATA_DIR"/icon-task.png";
	attr.pActionFunc = (CairoDockActionOnAnswerFunc) _set_warning_repetition;
	attr.pInteractiveWidget = pExtendedWidget;
	attr.pUserData = pTask;
	attr.iTimeLength = (pTask->iWarningDelay != 0 ? MIN (pTask->iWarningDelay-.1, 15.) : 15) * 60e3;  // on laisse le dialogue visible le plus longtemps possible, jusqu'a 15mn.
	const gchar *cDefaultActionButtons[3] = {"ok", "cancel", NULL};
	attr.cButtonsImage = cDefaultActionButtons;
	attr.pIcon = myIcon;
	attr.pContainer = myContainer;
	pTask->pWarningDialog = gldi_dialog_new (&attr);
	
	CD_APPLET_DEMANDS_ATTENTION (NULL, 3600);  // ~ 1h, pour si on loupe le dialogue.
	return TRUE;
}
static GtkWidget *_xgamma_add_channel_widget (GtkWidget *pInteractiveWidget, const gchar *cLabel, const gchar *cColor, int iChannelNumber, guint *iSignalID, double fChannelGamma)
{
	GtkWidget *pLabel = gtk_label_new (NULL);
	if (cColor)
	{
		gchar *cText = g_strdup_printf ("<span color=\"%s\">%s</span>", cColor, cLabel);
		gtk_label_set_markup (GTK_LABEL (pLabel), cText);
		g_free (cText);
	}
	else
	{
		gtk_label_set_text (GTK_LABEL (pLabel), cLabel);
		gldi_dialog_set_widget_text_color (pLabel); // default colour
	}

	gtk_grid_attach (GTK_GRID (pInteractiveWidget),
		pLabel,
		1,
		iChannelNumber+1,
		1,
		1);

	GtkWidget *pHScale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, GAMMA_MIN, GAMMA_MAX, .02);
	gtk_scale_set_digits (GTK_SCALE (pHScale), 2);
	gtk_range_set_value (GTK_RANGE (pHScale), fChannelGamma);
	g_object_set (pHScale, "width-request", 150, NULL);
	
	*iSignalID = g_signal_connect (G_OBJECT (pHScale),
		"value-changed",
		G_CALLBACK (on_scale_value_changed),
		GINT_TO_POINTER (iChannelNumber));
	gtk_grid_attach (GTK_GRID (pInteractiveWidget),
		pHScale,
		2,
		iChannelNumber+1,
		1,
		1);

	return pHScale;
}
Пример #8
0
static GtkWidget * create_slider (const char * name, int band, GtkWidget * hbox)
{
    GtkWidget * vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);

    GtkWidget * label = gtk_label_new (name);
    gtk_label_set_angle ((GtkLabel *) label, 90);
    gtk_box_pack_start ((GtkBox *) vbox, label, TRUE, FALSE, 0);

    GtkWidget * slider = gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL,
     -EQUALIZER_MAX_GAIN, EQUALIZER_MAX_GAIN, 1);
    gtk_scale_set_draw_value ((GtkScale *) slider, TRUE);
    gtk_scale_set_value_pos ((GtkScale *) slider, GTK_POS_BOTTOM);
    gtk_widget_set_size_request (slider, -1, 120);

    g_object_set_data ((GObject *) slider, "band", GINT_TO_POINTER (band));
    g_signal_connect ((GObject *) slider, "format-value", (GCallback) format_value, NULL);
    g_signal_connect ((GObject *) slider, "value-changed", (GCallback) slider_moved, NULL);

    gtk_box_pack_start ((GtkBox *) vbox, slider, FALSE, FALSE, 0);
    gtk_box_pack_start ((GtkBox *) hbox, vbox, FALSE, FALSE, 0);

    return slider;
}
Пример #9
0
static void
widget_overlay_set_property (GObject *object,
			     guint param_id,
			     const GValue *value,
			     GParamSpec *pspec)
{
	WidgetOverlay *ovl = WIDGET_OVERLAY (object);
	if (ovl->priv) {
                switch (param_id) {
                case PROP_ADD_SCALE: {
			gboolean need_scale;
			need_scale = g_value_get_boolean (value);
			if (!need_scale && !ovl->priv->scale_child)
				return;

			if (need_scale && ovl->priv->scale_child) {
				widget_overlay_set_child_props (ovl, ovl->priv->scale_child->child,
								WIDGET_OVERLAY_CHILD_ALPHA, .6,
								-1);
			}
			else if (need_scale) {
				GtkWidget *box, *wid, *button, *image;
				box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
				wid = gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL,
								SCALE_MIN, SCALE_MAX, SCALE_STEP);
				ovl->priv->scale_range = GTK_RANGE (wid);
				g_object_set (G_OBJECT (wid), "draw-value", FALSE, NULL);
				gtk_box_pack_start (GTK_BOX (box), wid, TRUE, TRUE, 0);

				button = gtk_button_new ();
				image = gtk_image_new_from_icon_name ("window-close-symbolic",
								  GTK_ICON_SIZE_MENU);
				gtk_container_add (GTK_CONTAINER (button), image);
				gtk_container_add (GTK_CONTAINER (box), button);
				gtk_widget_set_name (button, "browser-tab-close-button");
				g_signal_connect (button, "clicked",
						  G_CALLBACK (scale_button_clicked_cb), ovl);

				gtk_container_add (GTK_CONTAINER (ovl), box);
				gtk_widget_show_all (box);

				GList *list;
				for (list = ovl->priv->children; list; list = list->next) {
					ChildData *cd = (ChildData*) list->data;
					if (cd->child == box) {
						ovl->priv->scale_child = cd;
						break;
					}
				}
				g_assert (ovl->priv->scale_child);

				ChildData *cd;
				cd = get_first_child (ovl);
				if (cd)
					gtk_range_set_value (ovl->priv->scale_range, cd->scale);
				gtk_range_set_inverted (ovl->priv->scale_range, TRUE);

				g_signal_connect (wid, "value-changed",
						  G_CALLBACK (scale_value_changed_cb), ovl);

				widget_overlay_set_child_props (ovl, box,
								WIDGET_OVERLAY_CHILD_VALIGN,
								WIDGET_OVERLAY_ALIGN_FILL,
								WIDGET_OVERLAY_CHILD_HALIGN,
								WIDGET_OVERLAY_ALIGN_END,
								WIDGET_OVERLAY_CHILD_SCALE, 1.,
								WIDGET_OVERLAY_CHILD_ALPHA, .6,
								-1);
			}
			else {
				widget_overlay_set_child_props (ovl, ovl->priv->scale_child->child,
								WIDGET_OVERLAY_CHILD_ALPHA, 0.,
								-1);
			}
			break;
			}
		}
	}
}
Пример #10
0
bool RunLinuxDialog()
{
	GtkWidget *dialog;
	GtkWidget *main_box, *central_box, *advance_box, *res_box, *hw_box, *sw_box, *shader_box;
	GtkWidget  *native_box, *fsaa_box, *resxy_box, *renderer_box, *interlace_box, *threads_box, *filter_box;
	GtkWidget *hw_table, *shader_table, *res_frame, *hw_frame, *sw_frame, *shader_frame;
	GtkWidget *interlace_combo_box, *threads_spin;
	GtkWidget *interlace_label, *threads_label, *native_label,  *fsaa_label, *rexy_label, *render_label, *filter_label;

	GtkWidget *fsaa_combo_box, *render_combo_box, *filter_combo_box;
	GtkWidget *shader, *shader_conf, *shader_label, *shader_conf_label;
	GtkWidget *shadeboost_check, *paltex_check, *fba_check, *aa_check,  *native_res_check, *fxaa_check, *shaderfx_check;
	GtkWidget *sb_contrast, *sb_brightness, *sb_saturation;
	GtkWidget *resx_spin, *resy_spin;

	GtkWidget *hack_table, *hack_skipdraw_label, *hack_box, *hack_frame;
	GtkWidget *hack_alpha_check, *hack_date_check, *hack_offset_check, *hack_skipdraw_spin, *hack_msaa_check, *hack_sprite_check, * hack_wild_check, *hack_enble_check, *hack_logz_check;
	GtkWidget *hack_tco_label, *hack_tco_entry;
	GtkWidget *gl_box, *gl_frame, *gl_table;

	GtkWidget *notebook, *page_label[2];

	int return_value;

	GdkPixbuf* logo_pixmap;
	GtkWidget *logo_image;

	/* Create the widgets */
	dialog = gtk_dialog_new_with_buttons (
		"GSdx Config",
		NULL, /* parent window*/
		(GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
		"OK", GTK_RESPONSE_ACCEPT,
		"Cancel", GTK_RESPONSE_REJECT,
		NULL);

	// The main area for the whole dialog box.
	main_box = gtk_vbox_new(false, 5);
	central_box = gtk_vbox_new(false, 5);
	advance_box = gtk_vbox_new(false, 5);

	// The Internal resolution frame and container.
	res_box = gtk_vbox_new(false, 5);
	res_frame = gtk_frame_new ("OpenGL Internal Resolution (can cause glitches)");
	gtk_container_add(GTK_CONTAINER(res_frame), res_box);

	// The extra shader setting frame/container/table
	shader_box = gtk_vbox_new(false, 5);
	shader_frame = gtk_frame_new("Custom Shader Settings");
	gtk_container_add(GTK_CONTAINER(shader_frame), shader_box);
	shader_table = gtk_table_new(8,2, false);
	gtk_container_add(GTK_CONTAINER(shader_box), shader_table);

	// The hardware mode frame, container, and table.
	hw_box = gtk_vbox_new(false, 5);
	hw_frame = gtk_frame_new ("Hardware Mode Settings");
	gtk_container_add(GTK_CONTAINER(hw_frame), hw_box);
	hw_table = gtk_table_new(5,2, false);
	gtk_container_add(GTK_CONTAINER(hw_box), hw_table);

	// The software mode frame and container. (It doesn't have enough in it for a table.)
	sw_box = gtk_vbox_new(false, 5);
	sw_frame = gtk_frame_new ("Software Mode Settings");
	gtk_container_add(GTK_CONTAINER(sw_frame), sw_box);

	// The hack frame and container.
	hack_box = gtk_hbox_new(false, 5);
	hack_frame = gtk_frame_new ("Hacks");
	gtk_container_add(GTK_CONTAINER(hack_frame), hack_box);
	hack_table = gtk_table_new(3,3, false);
	gtk_container_add(GTK_CONTAINER(hack_box), hack_table);

	// Grab a logo, to make things look nice.
	logo_pixmap = gdk_pixbuf_from_pixdata(&gsdx_ogl_logo, false, NULL);
	logo_image = gtk_image_new_from_pixbuf(logo_pixmap);
	gtk_box_pack_start(GTK_BOX(main_box), logo_image, true, true, 0);

	// Create the renderer combo box and label, and stash them in a box.
	render_label = gtk_label_new ("Renderer:");
	render_combo_box = CreateRenderComboBox();
	renderer_box = gtk_hbox_new(false, 5);
	// Use gtk_box_pack_start instead of gtk_container_add so it lines up nicely.
	gtk_box_pack_start(GTK_BOX(renderer_box), render_label, false, false, 5);
	gtk_box_pack_start(GTK_BOX(renderer_box), render_combo_box, false, false, 5);

	// Create the interlace combo box and label, and stash them in a box.
	interlace_label = gtk_label_new ("Interlacing (F5):");
	interlace_combo_box = CreateInterlaceComboBox();
	interlace_box = gtk_hbox_new(false, 5);
	gtk_box_pack_start(GTK_BOX(interlace_box), interlace_label, false, false, 5);
	gtk_box_pack_start(GTK_BOX(interlace_box), interlace_combo_box, false, false, 5);

	// Create the filter combo box.
	filter_label = gtk_label_new ("Texture Filtering:");
	filter_combo_box = CreateFilterComboBox();
	filter_box = gtk_hbox_new(false, 5);
	gtk_box_pack_start(GTK_BOX(filter_box), filter_label, false, false, 5);
	gtk_box_pack_start(GTK_BOX(filter_box), filter_combo_box, false, false, 0);

	// Create the threading spin box and label, and stash them in a box. (Yes, we do a lot of that.)
	threads_label = gtk_label_new("Extra rendering threads:");
	threads_spin = gtk_spin_button_new_with_range(0,100,1);
	gtk_spin_button_set_value(GTK_SPIN_BUTTON(threads_spin), theApp.GetConfig("extrathreads", 0));
	threads_box = gtk_hbox_new(false, 0);
	gtk_box_pack_start(GTK_BOX(threads_box), threads_label, false, false, 5);
	gtk_box_pack_start(GTK_BOX(threads_box), threads_spin, false, false, 5);

	// A bit of funkiness for the resolution box.
	native_label = gtk_label_new("Original PS2 Resolution: ");
	native_res_check = gtk_check_button_new_with_label("Native");
	native_box = gtk_hbox_new(false, 5);
	gtk_box_pack_start(GTK_BOX(native_box), native_label, false, false, 5);
	gtk_box_pack_start(GTK_BOX(native_box), native_res_check, false, false, 5);

	fsaa_label = gtk_label_new("Or Use Scaling:");
	fsaa_combo_box = CreateMsaaComboBox();
	fsaa_box = gtk_hbox_new(false, 5);
	gtk_box_pack_start(GTK_BOX(fsaa_box), fsaa_label, false, false, 5);
	gtk_box_pack_start(GTK_BOX(fsaa_box), fsaa_combo_box, false, false, 5);

	rexy_label = gtk_label_new("Custom Resolution:");
	resx_spin = gtk_spin_button_new_with_range(256,8192,1);
	gtk_spin_button_set_value(GTK_SPIN_BUTTON(resx_spin), theApp.GetConfig("resx", 1024));
	resy_spin = gtk_spin_button_new_with_range(256,8192,1);
	gtk_spin_button_set_value(GTK_SPIN_BUTTON(resy_spin), theApp.GetConfig("resy", 1024));
	resxy_box = gtk_hbox_new(false, 5);
	gtk_box_pack_start(GTK_BOX(resxy_box), rexy_label, false, false, 5);
	gtk_box_pack_start(GTK_BOX(resxy_box), resx_spin, false, false, 5);
	gtk_box_pack_start(GTK_BOX(resxy_box), resy_spin, false, false, 5);

	// shader fx entry
	shader            = gtk_file_chooser_button_new("Select an external shader", GTK_FILE_CHOOSER_ACTION_OPEN);
	shader_conf       = gtk_file_chooser_button_new("Then select a config", GTK_FILE_CHOOSER_ACTION_OPEN);
	shader_label      = gtk_label_new("External shader glsl");
	shader_conf_label = gtk_label_new("External shader conf");

	// Create our hack settings.
	hack_alpha_check    = gtk_check_button_new_with_label("Alpha Hack");
	hack_date_check     = gtk_check_button_new_with_label("Date Hack");
	hack_offset_check   = gtk_check_button_new_with_label("Offset Hack");
	hack_skipdraw_label = gtk_label_new("Skipdraw:");
	hack_skipdraw_spin  = gtk_spin_button_new_with_range(0,1000,1);
	hack_enble_check    = gtk_check_button_new_with_label("Enable User Hacks");
	hack_wild_check     = gtk_check_button_new_with_label("Wild arm Hack");
	hack_sprite_check   = gtk_check_button_new_with_label("Sprite Hack");
	hack_msaa_check     = gtk_check_button_new_with_label("Msaa Hack");
	hack_tco_label      = gtk_label_new("Texture Offset: 0x");
	hack_tco_entry      = gtk_entry_new();
	hack_logz_check     = gtk_check_button_new_with_label("Log Depth Hack");

	gtk_spin_button_set_value(GTK_SPIN_BUTTON(hack_skipdraw_spin), theApp.GetConfig("UserHacks_SkipDraw", 0));
	set_hex_entry(hack_tco_entry, theApp.GetConfig("UserHacks_TCOffset", 0));

	// Tables are strange. The numbers are for their position: left, right, top, bottom.
	gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_alpha_check, 0, 1, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_offset_check, 1, 2, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_sprite_check, 0, 1, 1, 2);
	gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_wild_check, 1, 2, 1, 2);
	gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_logz_check, 0, 1, 2, 3);
	gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_date_check, 1, 2, 2, 3);
	// Note: MSAA is not implemented yet. I disable it to make the table square
	//gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_msaa_check, 2, 3, 1, 2);
	gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_skipdraw_label, 0, 1, 3, 4);
	gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_skipdraw_spin, 1, 2, 3, 4);
	gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_tco_label, 0, 1, 4, 5);
	gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_tco_entry, 1, 2, 4, 5);

	// Create our checkboxes.
	shadeboost_check = gtk_check_button_new_with_label("Shade boost");
	paltex_check     = gtk_check_button_new_with_label("Allow 8 bits textures");
	fba_check        = gtk_check_button_new_with_label("Alpha correction (FBA)");
	aa_check         = gtk_check_button_new_with_label("Edge anti-aliasing (AA1)");
	fxaa_check       = gtk_check_button_new_with_label("Fxaa shader");
	shaderfx_check   = gtk_check_button_new_with_label("External shader");

	// Set the checkboxes.
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(shadeboost_check), theApp.GetConfig("shadeboost", 1));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(paltex_check), theApp.GetConfig("paltex", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fba_check), theApp.GetConfig("fba", 1));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(aa_check), theApp.GetConfig("aa1", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fxaa_check), theApp.GetConfig("fxaa", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(shaderfx_check), theApp.GetConfig("shaderfx", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(native_res_check), theApp.GetConfig("nativeres", 0));

	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_alpha_check), theApp.GetConfig("UserHacks_AlphaHack", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_offset_check), theApp.GetConfig("UserHacks_HalfPixelOffset", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_date_check), theApp.GetConfig("UserHacks_DateGL4", 0));

	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_enble_check), theApp.GetConfig("UserHacks", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_msaa_check), theApp.GetConfig("UserHacks_MSAA", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_wild_check), theApp.GetConfig("UserHacks_WildHack", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_sprite_check), theApp.GetConfig("UserHacks_SpriteHack", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_logz_check), theApp.GetConfig("logz", 1));

	// Shadeboost scale
#if GTK_MAJOR_VERSION < 3
	sb_brightness = gtk_hscale_new_with_range(0, 200, 10);
#else
	sb_brightness = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0, 200, 10);
#endif
	GtkWidget* sb_brightness_label = gtk_label_new("Shade Boost Brightness");
	gtk_scale_set_value_pos(GTK_SCALE(sb_brightness), GTK_POS_RIGHT);
	gtk_range_set_value(GTK_RANGE(sb_brightness), theApp.GetConfig("ShadeBoost_Brightness", 50));

#if GTK_MAJOR_VERSION < 3
	sb_contrast = gtk_hscale_new_with_range(0, 200, 10);
#else
	sb_contrast = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0, 200, 10);
#endif
	GtkWidget* sb_contrast_label = gtk_label_new("Shade Boost Contrast");
	gtk_scale_set_value_pos(GTK_SCALE(sb_contrast), GTK_POS_RIGHT);
	gtk_range_set_value(GTK_RANGE(sb_contrast), theApp.GetConfig("ShadeBoost_Contrast", 50));

#if GTK_MAJOR_VERSION < 3
	sb_saturation = gtk_hscale_new_with_range(0, 200, 10);
#else
	sb_saturation = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0, 200, 10);
#endif
	GtkWidget* sb_saturation_label = gtk_label_new("Shade Boost Saturation");
	gtk_scale_set_value_pos(GTK_SCALE(sb_saturation), GTK_POS_RIGHT);
	gtk_range_set_value(GTK_RANGE(sb_saturation), theApp.GetConfig("ShadeBoost_Saturation", 50));

	// external shader entry
	gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(shader), theApp.GetConfig("shaderfx_glsl", "dummy.glsl").c_str());
	gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(shader_conf), theApp.GetConfig("shaderfx_conf", "dummy.ini").c_str());

	// Populate all those boxes we created earlier with widgets.
	gtk_container_add(GTK_CONTAINER(res_box), native_box);
	gtk_container_add(GTK_CONTAINER(res_box), fsaa_box);
	gtk_container_add(GTK_CONTAINER(res_box), resxy_box);

	gtk_container_add(GTK_CONTAINER(sw_box), threads_box);
	gtk_container_add(GTK_CONTAINER(sw_box), aa_check);

	// Tables are strange. The numbers are for their position: left, right, top, bottom.
	gtk_table_attach_defaults(GTK_TABLE(shader_table), fxaa_check, 0, 1, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), shadeboost_check, 0, 1, 1, 2);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_brightness_label, 0, 1, 2, 3);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_brightness, 1, 2, 2, 3);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_contrast_label, 0, 1, 3, 4);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_contrast, 1, 2, 3, 4);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_saturation_label, 0, 1, 4, 5);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_saturation, 1, 2, 4, 5);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), shaderfx_check, 0, 1, 5, 6);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), shader_label, 0, 1, 6, 7);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), shader, 1, 2, 6, 7);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), shader_conf_label, 0, 1, 7, 8);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), shader_conf, 1, 2, 7, 8);

	// Tables are strange. The numbers are for their position: left, right, top, bottom.
	gtk_table_attach_defaults(GTK_TABLE(hw_table), filter_box, 0, 1, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE(hw_table), paltex_check, 0, 1, 1, 2);
	gtk_table_attach_defaults(GTK_TABLE(hw_table), fba_check, 1, 2, 1, 2);

	// The GL advance options
	gl_box = gtk_vbox_new(false, 5);
	gl_frame = gtk_frame_new ("OpenGL Very Advanced Custom Settings");
	gtk_container_add(GTK_CONTAINER(gl_frame), gl_box);
	gl_table = gtk_table_new(10, 2, false);
	gtk_container_add(GTK_CONTAINER(gl_box), gl_table);

	GtkWidget* gl_bs_label = gtk_label_new("Buffer Storage:");
	GtkWidget* gl_bs_combo = CreateGlComboBox("override_GL_ARB_buffer_storage");
	GtkWidget* gl_bt_label = gtk_label_new("Bindless Texture:");
	GtkWidget* gl_bt_combo = CreateGlComboBox("override_GL_ARB_bindless_texture");
	GtkWidget* gl_sso_label = gtk_label_new("Separate Shader:");
	GtkWidget* gl_sso_combo = CreateGlComboBox("override_GL_ARB_separate_shader_objects");
	GtkWidget* gl_ss_label = gtk_label_new("Shader Subroutine:");
	GtkWidget* gl_ss_combo = CreateGlComboBox("override_GL_ARB_shader_subroutine");
	GtkWidget* gl_gs_label = gtk_label_new("Geometry Shader:");
	GtkWidget* gl_gs_combo = CreateGlComboBox("override_geometry_shader");
	GtkWidget* gl_ils_label = gtk_label_new("Image Load Store:");
	GtkWidget* gl_ils_combo = CreateGlComboBox("override_GL_ARB_shader_image_load_store");
	GtkWidget* gl_cc_label = gtk_label_new("Clip Control (depth accuracy):");
	GtkWidget* gl_cc_combo = CreateGlComboBox("override_GL_ARB_clip_control");
	GtkWidget* gl_ct_label = gtk_label_new("Clear Texture:");
	GtkWidget* gl_ct_combo = CreateGlComboBox("override_GL_ARB_clear_texture");

	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_gs_label, 0, 1, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_gs_combo, 1, 2, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_bs_label, 0, 1, 1, 2);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_bs_combo, 1, 2, 1, 2);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_bt_label, 0, 1, 2, 3);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_bt_combo, 1, 2, 2, 3);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_sso_label, 0, 1, 3, 4);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_sso_combo, 1, 2, 3, 4);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ss_label, 0, 1, 4, 5);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ss_combo, 1, 2, 4, 5);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ils_label, 0, 1, 5, 6);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ils_combo, 1, 2, 5, 6);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_cc_label, 0, 1, 6, 7);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_cc_combo, 1, 2, 6, 7);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ct_label, 0, 1, 7, 8);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ct_combo, 1, 2, 7, 8);
	// those one are properly detected so no need a gui
#if 0
override_GL_ARB_copy_image = -1
override_GL_ARB_explicit_uniform_location = -1
override_GL_ARB_gpu_shader5 = -1
override_GL_ARB_shading_language_420pack = -1
#endif

	// Handle some nice tab
	notebook = gtk_notebook_new();
	page_label[0] = gtk_label_new("Global Setting");
	page_label[1] = gtk_label_new("Advance Setting");

	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), central_box, page_label[0]);
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), advance_box, page_label[1]);

	// Put everything in the big box.
	gtk_container_add(GTK_CONTAINER(main_box), renderer_box);
	gtk_container_add(GTK_CONTAINER(main_box), interlace_box);
	gtk_container_add(GTK_CONTAINER(main_box), notebook);

	gtk_container_add(GTK_CONTAINER(central_box), res_frame);
	gtk_container_add(GTK_CONTAINER(central_box), shader_frame);
	gtk_container_add(GTK_CONTAINER(central_box), hw_frame);
	gtk_container_add(GTK_CONTAINER(central_box), sw_frame);

	gtk_container_add(GTK_CONTAINER(advance_box), hack_frame);
	gtk_container_add(GTK_CONTAINER(advance_box), gl_frame);

	// Put the box in the dialog and show it to the world.
	gtk_container_add (GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_box);
	gtk_widget_show_all (dialog);
	return_value = gtk_dialog_run (GTK_DIALOG (dialog));

	if (return_value == GTK_RESPONSE_ACCEPT)
	{
		int mode_height = 0, mode_width = 0;

		mode_width = theApp.GetConfig("ModeWidth", 640);
		mode_height = theApp.GetConfig("ModeHeight", 480);
		theApp.SetConfig("ModeHeight", mode_height);
		theApp.SetConfig("ModeWidth", mode_width);

		// Get all the settings from the dialog box.
		if (gtk_combo_box_get_active(GTK_COMBO_BOX(render_combo_box)) != -1) {
			// Note the value are based on m_gs_renderers vector on GSdx.cpp
			switch (gtk_combo_box_get_active(GTK_COMBO_BOX(render_combo_box))) {
				case 0: theApp.SetConfig("renderer", 10); break;
				case 1: theApp.SetConfig("renderer", 16); break;
				case 2: theApp.SetConfig("renderer", 11); break;
				case 3: theApp.SetConfig("renderer", 12); break;
				case 4: theApp.SetConfig("renderer", 13); break;
				case 5: theApp.SetConfig("renderer", 17); break;

				// Fallback to SW opengl
				default: theApp.SetConfig("renderer", 13); break;
			}
		}

		if (gtk_combo_box_get_active(GTK_COMBO_BOX(interlace_combo_box)) != -1)
			theApp.SetConfig( "interlace", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(interlace_combo_box)));

		theApp.SetConfig("extrathreads", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(threads_spin)));

		theApp.SetConfig("filter", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(filter_combo_box)));
		theApp.SetConfig("shadeboost", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(shadeboost_check)));
		theApp.SetConfig("paltex", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(paltex_check)));
		theApp.SetConfig("fba", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fba_check)));
		theApp.SetConfig("aa1", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(aa_check)));
		theApp.SetConfig("fxaa", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fxaa_check)));
		theApp.SetConfig("shaderfx", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(shaderfx_check)));
		theApp.SetConfig("nativeres", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(native_res_check)));

		theApp.SetConfig("shaderfx_glsl", gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(shader)));
		theApp.SetConfig("shaderfx_conf", gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(shader_conf)));

		theApp.SetConfig("ShadeBoost_Saturation", (int)gtk_range_get_value(GTK_RANGE(sb_saturation)));
		theApp.SetConfig("ShadeBoost_Brightness", (int)gtk_range_get_value(GTK_RANGE(sb_brightness)));
		theApp.SetConfig("ShadeBoost_Contrast", (int)gtk_range_get_value(GTK_RANGE(sb_contrast)));

		theApp.SetConfig("upscale_multiplier", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(fsaa_combo_box))+1);
		theApp.SetConfig("resx", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(resx_spin)));
		theApp.SetConfig("resy", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(resy_spin)));

		theApp.SetConfig("UserHacks_SkipDraw", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(hack_skipdraw_spin)));
		theApp.SetConfig("UserHacks_HalfPixelOffset", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_offset_check)));
		theApp.SetConfig("UserHacks_AlphaHack", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_alpha_check)));
		theApp.SetConfig("logz", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_logz_check)));
		theApp.SetConfig("UserHacks_DateGL4", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_date_check)));

		theApp.SetConfig("UserHacks_MSAA", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_msaa_check)));
		theApp.SetConfig("UserHacks_WildHack", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_wild_check)));
		theApp.SetConfig("UserHacks_SpriteHack", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_sprite_check)));
		theApp.SetConfig("UserHacks", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_enble_check)));
		theApp.SetConfig("UserHacks_TCOffset", get_hex_entry(hack_tco_entry));

		theApp.SetConfig("override_GL_ARB_clear_texture", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_ct_combo)) - 1);
		theApp.SetConfig("override_GL_ARB_bindless_texture", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_bt_combo)) - 1);
		theApp.SetConfig("override_GL_ARB_buffer_storage", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_bs_combo)) - 1);
		theApp.SetConfig("override_GL_ARB_separate_shader_objects", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_sso_combo)) - 1);
		theApp.SetConfig("override_GL_ARB_shader_subroutine", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_ss_combo)) - 1);
		theApp.SetConfig("override_geometry_shader", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_gs_combo)) - 1);
		theApp.SetConfig("override_GL_ARB_shader_image_load_store", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_ils_combo)) - 1);
		theApp.SetConfig("override_GL_ARB_clip_control", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_cc_combo)) - 1);

		// NOT supported yet
		theApp.SetConfig("msaa", 0);

		// Let's just be windowed for the moment.
		theApp.SetConfig("windowed", 1);

		gtk_widget_destroy (dialog);

		return true;
	}

	gtk_widget_destroy (dialog);

	return false;
}
Пример #11
0
int main(int argc, char *argv[])
{
	printf("%s \nPlease report any bug to %s\n", PACKAGE_STRING, PACKAGE_BUGREPORT);	
	//printf("number of arg = %d, argv = %s\n", argc, argv[1]);
	/*printf("argc = %d\n", argc);
	if (argv[1] != NULL) {
		if (strstr (argv[1],"debug") != NULL) {
		debug = TRUE;
		printf("debug = TRUE\n");
			}  
		}
	DEBUG("debug is true\n");*/
	gchar *filename;
	int i = 0;
	gint initialWindowHeight = 170;
	guint timeoutEvent, intervalDisplaySpectro;
	GtkWidget *pVBox[4], *pHBox[13], *menuBar, *menu, *submenu, *menuItem, *submenuItem, *button, *frame, *image, *label, *widget;
	GdkColor color;
	Spectrum3dGui spectrum3dGui;
	GSList *radio_menu_group;
	GError **error;

#if defined (GTKGLEXT3) || defined (GTKGLEXT1)
	GdkGLConfig *glconfig;
#endif 
	
	gst_init (NULL, NULL);
	gtk_init (&argc, &argv);

	get_saved_values();
	intervalDisplaySpectro = (guint)spectrum3d.interval_display;

#if defined (GTKGLEXT3) || defined (GTKGLEXT1)
	gtk_gl_init(NULL, NULL);
	glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB    |
					GDK_GL_MODE_DEPTH  |
					GDK_GL_MODE_DOUBLE);
	  if (glconfig == NULL)
	    {
	      g_print ("\n*** Cannot find the double-buffered visual.\n");
	      g_print ("\n*** Trying single-buffered visual.\n");

	      /* Try single-buffered visual */
	      glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB   |
						    GDK_GL_MODE_DEPTH);
	      if (glconfig == NULL)
		{
		  g_print ("*** No appropriate OpenGL-capable visual found.\n");
		  exit (1);
		}
	    }
#endif

	initGstreamer();
	init_audio_values();
	init_display_values(&spectrum3dGui);
	
	spectrum3dGui.mainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_widget_set_size_request (spectrum3dGui.mainWindow, 700, initialWindowHeight);
	gtk_widget_realize(spectrum3dGui.mainWindow);
	gtk_window_set_title(GTK_WINDOW(spectrum3dGui.mainWindow), PACKAGE_NAME);
	filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "spectrum3d.png", NULL);
	gtk_window_set_icon(GTK_WINDOW(spectrum3dGui.mainWindow), gdk_pixbuf_new_from_file (filename, error));
	g_signal_connect (G_OBJECT (spectrum3dGui.mainWindow), "destroy", G_CALLBACK (quit_spectrum3d), NULL);

#ifdef GTK3
	gtk_container_set_reallocate_redraws (GTK_CONTAINER (spectrum3dGui.mainWindow), TRUE);
#endif

#ifdef GTK3
	for (i = 0; i < 4; i++) {
		pVBox[i] = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
		}
	pHBox[0] = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	for (i = 1; i < 12; i++) {
		pHBox[i] = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
		}
	pHBox[12] = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
#elif defined GTK2
	for (i = 0; i < 4; i++) {
		pVBox[i] = gtk_vbox_new(FALSE, 0);
		}
	pHBox[0] = gtk_hbox_new(TRUE, 0);
	for (i = 1; i < 12; i++) {
		pHBox[i] = gtk_hbox_new(FALSE, 0);
		}
	pHBox[12] = gtk_hbox_new(TRUE, 0);
#endif
	
	gtk_container_add(GTK_CONTAINER(spectrum3dGui.mainWindow), pVBox[1]); 
	gtk_box_pack_start(GTK_BOX(pVBox[1]), pHBox[0], FALSE, FALSE, 0);
		
/* Menu */
	menuBar = gtk_menu_bar_new();

	menu = gtk_menu_new(); // 'Quit' submenu
	menuItem = gtk_menu_item_new_with_label("Quit");
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);    
	g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(gtk_main_quit), NULL); 
	menuItem = gtk_menu_item_new_with_label("Quit");
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), menu);
	gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuItem);

	menu = gtk_menu_new(); // 'Edit' submenu
        menuItem = gtk_menu_item_new_with_label("Preferences");
	g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(onPreferences), &spectrum3dGui);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);
	menuItem = gtk_menu_item_new_with_label("Edit");
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), menu);
	gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuItem);

	menu = gtk_menu_new(); // 'Sound' submenu
	menuItem = gtk_menu_item_new_with_label("Sound");
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), menu);
	gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuItem);

		submenu = gtk_menu_new();// 'Play test sound' sub-submenu
		spectrum3dGui.checkMenuTestSound = gtk_check_menu_item_new_with_label("Test Sound");
		gtk_menu_shell_append(GTK_MENU_SHELL(menu), spectrum3dGui.checkMenuTestSound);
		g_signal_connect(G_OBJECT(spectrum3dGui.checkMenuTestSound), "activate", G_CALLBACK(menu_check_test_sound), &spectrum3dGui);

	menu = gtk_menu_new(); // 'View' submenu
	menuItem = gtk_menu_item_new_with_label("View");
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), menu);
	gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuItem);
	
		submenu = gtk_menu_new();// 'viewType' sub-submenu
		menuItem = gtk_menu_item_new_with_label("Perspective");
		gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuItem), submenu);
		gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);	
			
			spectrum3dGui.radio3D = gtk_radio_menu_item_new_with_label(NULL, "3D (D)");
			radio_menu_group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(spectrum3dGui.radio3D));
			g_signal_connect(G_OBJECT(spectrum3dGui.radio3D), "toggled", G_CALLBACK(change_perspective), spectrum3dGui.radio3D);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.radio3D);

			spectrum3dGui.radio3Dflat = gtk_radio_menu_item_new_with_label(radio_menu_group, "3D flat (F)");
			radio_menu_group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(spectrum3dGui.radio3Dflat));
			g_signal_connect(G_OBJECT(spectrum3dGui.radio3Dflat), "toggled", G_CALLBACK(change_perspective), spectrum3dGui.radio3Dflat);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.radio3Dflat);

			spectrum3dGui.radio2D = gtk_radio_menu_item_new_with_label(radio_menu_group, "2D (D)");
			radio_menu_group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(spectrum3dGui.radio2D));
			g_signal_connect(G_OBJECT(spectrum3dGui.radio2D), "toggled", G_CALLBACK(change_perspective), spectrum3dGui.radio2D);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.radio2D);

		submenu = gtk_menu_new();// 'Scale' sub-submenu
		menuItem = gtk_menu_item_new_with_label("Scale");
		gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuItem), submenu);
		gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);	
	
			spectrum3dGui.checkMenuText = gtk_check_menu_item_new_with_label("Text (T)");
			gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(spectrum3dGui.checkMenuText), TRUE);
			g_signal_connect(G_OBJECT(spectrum3dGui.checkMenuText), "activate", G_CALLBACK(check_menu_text), &spectrum3dGui);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.checkMenuText);
	
			spectrum3dGui.checkMenuLines = gtk_check_menu_item_new_with_label("Lines (L)");
			gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(spectrum3dGui.checkMenuLines), TRUE);
			g_signal_connect(G_OBJECT(spectrum3dGui.checkMenuLines), "activate", G_CALLBACK(check_menu_lines), &spectrum3dGui);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.checkMenuLines);

			spectrum3dGui.checkMenuPointer = gtk_check_menu_item_new_with_label("Pointer (P)");
			g_signal_connect(G_OBJECT(spectrum3dGui.checkMenuPointer), "activate", G_CALLBACK(check_menu_pointer), &spectrum3dGui);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.checkMenuPointer);

		submenu = gtk_menu_new();// 'Change/reset view' sub-submenu
		menuItem = gtk_menu_item_new_with_label("Change/reset view");
		gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuItem), submenu);
		gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);	
			
			spectrum3dGui.reset = gtk_menu_item_new_with_label("Reset view (R)");
			gtk_widget_set_tooltip_text (spectrum3dGui.reset, "Reset the view as if Spectrum3d was just started");
			g_signal_connect(G_OBJECT(spectrum3dGui.reset), "activate", G_CALLBACK(reset_view), spectrum3dGui.reset);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.reset);

			spectrum3dGui.front = gtk_menu_item_new_with_label("Front view (O)");
			gtk_widget_set_tooltip_text (spectrum3dGui.front, "2D view showing frequency versus intensity of the sound; shows a snapshot of the harmonics at a given time");
			g_signal_connect(G_OBJECT(spectrum3dGui.front), "activate", G_CALLBACK(front_view), spectrum3dGui.front);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.front);

			submenuItem = gtk_menu_item_new_with_label("Preset view");
			gtk_widget_set_tooltip_text (submenuItem, "Set the view with the chosen preset values");
			g_signal_connect(G_OBJECT(submenuItem), "activate", G_CALLBACK(set_view_from_preset), submenuItem);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), submenuItem);

	menu = gtk_menu_new(); // 'Help...' submenu
	menuItem = gtk_menu_item_new_with_label("Shortcuts"); 
	g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(onShortcuts), (GtkWidget*) spectrum3dGui.mainWindow);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);
#ifdef HAVE_LIBGEIS
	menuItem = gtk_menu_item_new_with_label("Gestures Shortcuts");
	g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(onGesturesShortcuts), (GtkWidget*) spectrum3dGui.mainWindow);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);
#endif 
	menuItem = gtk_menu_item_new_with_label("About...");
	g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(onAbout), (GtkWidget*) spectrum3dGui.mainWindow);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);
	menuItem = gtk_menu_item_new_with_label("Quick start");
	g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(onQuickStart), (GtkWidget*) spectrum3dGui.mainWindow);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);
	menuItem = gtk_menu_item_new_with_label("Help");
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), menu);
	gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuItem);
	gtk_box_pack_start(GTK_BOX(pHBox[0]), menuBar, FALSE, TRUE, 0);

/* SourceButtons to set type of source (none, audio file, microphone) */
	spectrum3dGui.stop = gtk_button_new();
	filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "stop.png", NULL);
	image = gtk_image_new_from_file(filename);
	gtk_button_set_image(GTK_BUTTON(spectrum3dGui.stop),image);
	gdk_color_parse ("gold",&color);
	gtk_widget_set_name(spectrum3dGui.stop, "stop");
	gtk_widget_modify_bg(GTK_WIDGET(spectrum3dGui.stop), GTK_STATE_NORMAL, &color);
	gtk_widget_modify_bg(GTK_WIDGET(spectrum3dGui.stop), GTK_STATE_PRELIGHT, &color);
	gtk_widget_set_tooltip_text (spectrum3dGui.stop, "Stop playing everything; no source of playing");
	gtk_box_pack_start(GTK_BOX(pVBox[1]), pHBox[1], FALSE, TRUE, 2);
	gtk_box_pack_start(GTK_BOX(pHBox[1]), spectrum3dGui.stop, FALSE, TRUE, 2);
	g_signal_connect(G_OBJECT(spectrum3dGui.stop), "clicked", G_CALLBACK(change_source_button), &spectrum3dGui);

	filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "microphone_grey.png", NULL);
	image = gtk_image_new_from_file(filename);
	spectrum3dGui.mic = gtk_button_new();
	gtk_button_set_image (GTK_BUTTON(spectrum3dGui.mic), image);
	gtk_widget_set_name(spectrum3dGui.mic, "mic");
	gtk_widget_set_tooltip_text (spectrum3dGui.mic, "Source is microphone; select this to record something and then load it");
	gtk_box_pack_start(GTK_BOX(pHBox[1]), spectrum3dGui.mic, FALSE, TRUE, 2);
	g_signal_connect(G_OBJECT(spectrum3dGui.mic), "clicked", G_CALLBACK(change_source_button), &spectrum3dGui);

	spectrum3dGui.file = gtk_button_new();
	filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "file_grey.png", NULL);
	image = gtk_image_new_from_file(filename);
	gtk_button_set_image(GTK_BUTTON(spectrum3dGui.file),image);
	gtk_widget_set_name(spectrum3dGui.file, "file");
	gtk_widget_set_tooltip_text (spectrum3dGui.file, "Source is an audio file");
	gtk_box_pack_start(GTK_BOX(pHBox[1]), spectrum3dGui.file, FALSE, FALSE, 2);
	g_signal_connect(G_OBJECT(spectrum3dGui.file), "clicked", G_CALLBACK(change_source_button), &spectrum3dGui);

	spectrum3dGui.reload = gtk_button_new();
	image = gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_LARGE_TOOLBAR);
	gtk_button_set_image(GTK_BUTTON(spectrum3dGui.reload),image);
	gtk_widget_set_sensitive (spectrum3dGui.reload, FALSE);
	gtk_widget_set_tooltip_text (spectrum3dGui.reload, "Reload audio file (usefull if some audio parameters like equalizer or filters have been changed)");
	gtk_box_pack_start(GTK_BOX(pHBox[1]), spectrum3dGui.reload, FALSE, FALSE, 2);
	g_signal_connect(G_OBJECT(spectrum3dGui.reload), "clicked", G_CALLBACK(load_audio_file), NULL);

	widget = gtk_check_button_new_with_label("Analyse in\nrealtime");
	gtk_widget_set_tooltip_text (GTK_WIDGET(widget), "If checked, harmonics will be analysed and displayed at the same time; if unchecked, harmonics will be analysed first, then displayed for the whole audio file, then it can be played afterwards");
	gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 0);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(widget), TRUE);
	g_signal_connect(G_OBJECT(widget), "toggled", G_CALLBACK(set_analyse_in_rt), &spectrum3dGui);

/* separator */
#ifdef GTK3
	widget = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
#elif defined GTK2
	widget = gtk_vseparator_new();
#endif
	gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 5);
	
/* "Play/Pause" button */
	playButton = gtk_button_new();
	gtk_widget_set_tooltip_text (playButton, "Play/Pause the audio stream");
	setPlayButtonIcon();
	gtk_widget_set_size_request (playButton, 50, 20);
	gtk_box_pack_start(GTK_BOX(pHBox[1]), playButton, FALSE, FALSE, 2);
	g_signal_connect(G_OBJECT(playButton), "clicked", G_CALLBACK(playFromSource), "NO_MESSAGE");
	
/* "Stop" button */
	button = gtk_button_new();
	gtk_widget_set_tooltip_text (button, "Stop playing audio stream");
	image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_STOP, GTK_ICON_SIZE_SMALL_TOOLBAR);
	gtk_button_set_image(GTK_BUTTON(button),image);
	gtk_box_pack_start(GTK_BOX(pHBox[1]), button, FALSE, FALSE, 2);
	g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(on_stop), NULL);

/* "Record" button */
	spectrum3dGui.record = gtk_button_new();
	gtk_widget_set_tooltip_text (spectrum3dGui.record, "Record from microphone");
	image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_RECORD, GTK_ICON_SIZE_SMALL_TOOLBAR);
	gtk_button_set_image(GTK_BUTTON(spectrum3dGui.record),image);
	gtk_widget_set_sensitive (spectrum3dGui.record, FALSE);
	gtk_box_pack_start(GTK_BOX(pHBox[1]), spectrum3dGui.record, FALSE, FALSE, 2);
	g_signal_connect(G_OBJECT(spectrum3dGui.record), "clicked", G_CALLBACK(record_window), NULL);

/* separator */
#ifdef GTK3
	widget = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
#elif defined GTK2
	widget = gtk_vseparator_new();
#endif	
	gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 5);

/* JACK check button */
	filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "qjackctl.png", NULL);
	image = gtk_image_new_from_file(filename);
	widget = gtk_check_button_new ();
	gtk_button_set_image (GTK_BUTTON(widget), image);
	gtk_widget_set_tooltip_text (widget, "Use Jack-Audio-Connection-Kit (JACK)");
	gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 2);
	g_signal_connect(G_OBJECT(widget), "toggled", G_CALLBACK(use_jack), &spectrum3dGui);

/* separator */
#ifdef GTK3
	widget = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
#elif defined GTK2
	widget = gtk_vseparator_new();
#endif	
	gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 5);

/* Button to open the Filter and Equalizer window */
	// create effectsWindow first without showing it
	effects_window(&spectrum3dGui);
	// then create a button that will call its display when clicked
	filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "equalizer.png", NULL);
	image = gtk_image_new_from_file(filename);
	widget = gtk_button_new();  
	gtk_button_set_image (GTK_BUTTON(widget), image);
	gtk_widget_set_tooltip_text (widget, "Show/Hide the filter and equalizer window");
	gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 0);
	g_signal_connect(G_OBJECT(widget), "clicked", G_CALLBACK(show_effects_window), &spectrum3dGui);

/* Time label */
	label=gtk_label_new("Time : ");
	gtk_box_pack_start(GTK_BOX(pHBox[5]), label, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(pVBox[1]), pHBox[5], FALSE, FALSE, 2);

/* Progress & seek scale */
#ifdef GTK3
	scaleSeek = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0.0, 100.0, 1);
#elif defined GTK2
	scaleSeek = gtk_hscale_new_with_range (0.0, 100.0, 1);
#endif
	gtk_scale_set_draw_value (GTK_SCALE (scaleSeek), FALSE);
	//gtk_scale_set_value_pos (GTK_SCALE (pScaleSeek), GTK_POS_TOP);
	gtk_range_set_value (GTK_RANGE (scaleSeek), 0);
	gtk_widget_set_size_request (scaleSeek, 500, 20);
	gtk_box_pack_start(GTK_BOX(pHBox[5]), scaleSeek, FALSE, FALSE, 0);
	g_signal_connect(G_OBJECT(scaleSeek), "value-changed", G_CALLBACK(on_seek), NULL);
	
	timeLabel=gtk_label_new("           0:00 / 0:00           ");
	gtk_box_pack_start(GTK_BOX(pHBox[5]), timeLabel, FALSE, FALSE, 0);

/* Create drawing area */
	if (externalWindow == FALSE){
		/* Resize spectrum3dGui.mainWindow to contain drawing_area; using gtk_window_set_defaut() allows to shrink the window (gtk_widget_set_size_request() does not allow to shrink the window below the requested size); */
		gtk_window_set_default_size (GTK_WINDOW(spectrum3dGui.mainWindow), (gint)spectrum3d.width, initialWindowHeight + (gint)spectrum3d.height);
		
		//gtk_widget_realize(spectrum3dGui.mainWindow);

		spectrum3dGui.drawing_area = gtk_drawing_area_new ();
		
#if defined (GTKGLEXT3) || defined (GTKGLEXT1)
		/* Set OpenGL-capability to the widget */
	  	gtk_widget_set_gl_capability (spectrum3dGui.drawing_area,
					glconfig,
					NULL,
					TRUE,
					GDK_GL_RGBA_TYPE);		
#endif	
		
		/* drawing_area has to be put in vBox AFTER the call to gtk_widget_set_gl_capability() (if GtkGlExt is used) and BEFORE the call to the sdl-gtk hack (if sdl is used)*/ 
		gtk_box_pack_start (GTK_BOX (pVBox[1]), spectrum3dGui.drawing_area, TRUE, TRUE, 0);	
		
#ifdef HAVE_LIBSDL 
		/* Hack to get SDL to use GTK window */
		{ char SDL_windowhack[32];
			sprintf(SDL_windowhack,"SDL_WINDOWID=%ld",
				GDK_WINDOW_XID(gtk_widget_get_window(spectrum3dGui.drawing_area)));
				// GDK_WINDOW_XID( spectrum3dGui.drawing_area->window))); pour GTK2??
			putenv(SDL_windowhack);
		printf("%s\n", SDL_windowhack);
		}

		if (SDL_Init(SDL_INIT_VIDEO) < 0) {
			fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
			exit(1);
			}
#endif

		g_signal_connect (spectrum3dGui.mainWindow, "key-press-event", G_CALLBACK (on_key_press), &spectrum3dGui);
		g_signal_connect (spectrum3dGui.mainWindow, "key-release-event", G_CALLBACK (on_key_release), &spectrum3dGui);
		g_signal_connect (spectrum3dGui.mainWindow, "motion-notify-event", G_CALLBACK (on_mouse_motion), NULL);
		g_signal_connect (spectrum3dGui.mainWindow, "scroll-event", G_CALLBACK (on_mouse_scroll), NULL);
		g_signal_connect (G_OBJECT (spectrum3dGui.drawing_area), "configure_event", G_CALLBACK (configure_event), NULL);
		gtk_widget_add_events (spectrum3dGui.mainWindow, gtk_widget_get_events (spectrum3dGui.mainWindow) | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK);
	}
	else {
		create_external_window_drawing_area(&spectrum3dGui);
		}	

/* Starting value of the display */
	frame = gtk_frame_new("Start value of display (in Hz)");
	gtk_widget_set_tooltip_text (frame, "The lower displayed frequency (in herz)");
	spectrum3dGui.adjustStart = gtk_adjustment_new(0, 0, 9000, ((gdouble)hzStep * (gdouble)zoomFactor), (((gdouble)hzStep * (gdouble)zoomFactor) * 10), 0);
#ifdef GTK3
	pScaleStart = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT(spectrum3dGui.adjustStart));
#elif defined GTK2
	pScaleStart = gtk_hscale_new(GTK_ADJUSTMENT(spectrum3dGui.adjustStart));
#endif
	gtk_scale_set_digits (GTK_SCALE(pScaleStart), 0);
	gtk_scale_set_value_pos(GTK_SCALE(pScaleStart), GTK_POS_RIGHT);
	gtk_box_pack_start(GTK_BOX(pVBox[1]), pHBox[11], FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(pHBox[11]), frame, FALSE, FALSE, 0);
	gtk_container_add(GTK_CONTAINER(frame), pScaleStart);
	g_signal_connect(G_OBJECT(pScaleStart), "value-changed", G_CALLBACK(change_start), &spectrum3dGui);
	g_signal_connect(G_OBJECT(pScaleStart), "format-value", G_CALLBACK(format_value_start), NULL);
	g_signal_connect(G_OBJECT(pScaleStart), "value-changed", G_CALLBACK(getTextDisplayLabel), &spectrum3dGui);

/* Range of display */
	frame = gtk_frame_new("Range of display (in Hz)");
	gtk_widget_set_tooltip_text (frame, "The range of the displayed frequency (in herz)");
	spectrum3dGui.adjustBands = gtk_adjustment_new(1000, 20, 1000, 10, 50, 0);
#ifdef GTK3
	spectrum3dGui.scaleBands = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT(spectrum3dGui.adjustBands));
#elif defined GTK2
	spectrum3dGui.scaleBands = gtk_hscale_new(GTK_ADJUSTMENT(spectrum3dGui.adjustBands));
#endif
	gtk_scale_set_digits (GTK_SCALE(spectrum3dGui.scaleBands), 0);
	gtk_scale_set_value_pos(GTK_SCALE(spectrum3dGui.scaleBands), GTK_POS_RIGHT);
	gtk_container_add(GTK_CONTAINER(frame), spectrum3dGui.scaleBands);
	gtk_box_pack_start(GTK_BOX(pHBox[11]), frame, FALSE, FALSE, 0);
	g_signal_connect(G_OBJECT(spectrum3dGui.scaleBands), "value-changed", G_CALLBACK(change_bands), &spectrum3dGui);
	g_signal_connect(G_OBJECT(spectrum3dGui.scaleBands), "format-value", G_CALLBACK(format_value_bands), NULL);
	g_signal_connect(G_OBJECT(spectrum3dGui.scaleBands), "value-changed", G_CALLBACK(getTextDisplayLabel), &spectrum3dGui);
	
/* "x" label */
	label=gtk_label_new("x");
	gtk_container_add(GTK_CONTAINER(pHBox[11]), label);

/* Factor that multiplies the range of display */
	frame = gtk_frame_new("");
	gtk_widget_set_tooltip_text (frame, "Factor that multiplies the frequency range, to make it larger");
	spectrum3dGui.cbRange = gtk_combo_box_text_new();
	gtk_container_add(GTK_CONTAINER(frame), spectrum3dGui.cbRange);
	gtk_box_pack_start(GTK_BOX(pHBox[11]), frame, FALSE, FALSE, 0);
	for (i = 1; i <= 20; i++){
		gchar text[4];
		sprintf(text, "%d", i);
		gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(spectrum3dGui.cbRange), text);
		}
	gtk_combo_box_set_active(GTK_COMBO_BOX(spectrum3dGui.cbRange), 0);
	g_signal_connect( G_OBJECT(spectrum3dGui.cbRange), "changed", G_CALLBACK( cb_range_changed ), &spectrum3dGui );
	g_signal_connect( G_OBJECT(spectrum3dGui.cbRange), "changed", G_CALLBACK(getTextDisplayLabel), &spectrum3dGui );
	
/* Label that shows starting value, ending value and range of display */
	frame = gtk_frame_new("Values displayed");
	gtk_widget_set_tooltip_text (frame, "The lower and the highest displayed value (in herz), and their range");
	displayLabel=gtk_label_new(""); 
	gtk_container_add(GTK_CONTAINER(frame), displayLabel);
	getTextDisplayLabel(NULL, &spectrum3dGui);
	gtk_box_pack_start(GTK_BOX(pHBox[11]), frame, FALSE, FALSE, 0);

/* 'Gain' Gtk Scale */
	frame = gtk_frame_new("Display Gain");
	gtk_box_pack_start(GTK_BOX(pHBox[11]), frame, FALSE, FALSE, 10);
	filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "gain.png", NULL);
	image = gtk_image_new_from_file(filename);

	spectrum3dGui.scaleGain = gtk_scale_button_new (GTK_ICON_SIZE_LARGE_TOOLBAR, 0, 1, 0.01, NULL);
	gtk_button_set_image(GTK_BUTTON(spectrum3dGui.scaleGain),image);
	//gtk_button_set_label (GTK_BUTTON(spectrum3dGui.scaleGain), "GAIN");
	gtk_container_add(GTK_CONTAINER(frame), spectrum3dGui.scaleGain);
	//gtk_box_pack_start(GTK_BOX(pHBox[11]), pScaleGain, FALSE, FALSE, 0);
	//gtk_widget_set_size_request (pScaleGain, 200, 20);
	//gtk_scale_set_value_pos(GTK_SCALE(pScaleGain), GTK_POS_RIGHT);
	gtk_widget_set_tooltip_text (spectrum3dGui.scaleGain, "Adjust the displayed level of the intensity of the sound");
	gtk_scale_button_set_value(GTK_SCALE_BUTTON(spectrum3dGui.scaleGain), 0.2);
	// FIXME error message here with the previous line : gtk_image_set_from_stock: assertion `GTK_IS_IMAGE (image)' failed; it could be a bug in Gtk
	//g_object_set (pScaleGain, "update-policy", GTK_UPDATE_DISCONTINUOUS, NULL);
	g_signal_connect(G_OBJECT(spectrum3dGui.scaleGain), "value-changed", G_CALLBACK(change_gain), NULL);

#ifdef HAVE_LIBGEIS
	setupGeis();
#endif

	gtk_widget_show_all (spectrum3dGui.mainWindow);

	//timeoutEvent = g_timeout_add (100, (GSourceFunc)sdl_event, &spectrum3dGui);
	spectrum3d.timeoutExpose = g_timeout_add (intervalDisplaySpectro, (GSourceFunc)display_spectro, &spectrum3dGui);

	printf("Showing Gtk GUI\n");
	gtk_main ();

/* Quit everything */

#ifdef HAVE_LIBGEIS
	geisQuit();
#endif
	on_stop();
	g_source_remove(spectrum3d.timeoutExpose);
#ifdef HAVE_LIBSDL
	//g_source_remove(timeoutEvent);
	SDL_Quit();
#endif

	print_rc_file();

	printf("Quit everything\nGood Bye!\n");
	
	return 0;
}
Пример #12
0
int main (int argc, char *argv[])
{
    GtkWidget *window;
    GtkWidget *box;
    GtkWidget *box1;
    GtkWidget *box2;
    GtkWidget *button;
    GtkWidget *frame;
    GtkWidget *scale;
    const gchar *labels[3] = {
        "<small>Left</small>",
        "<small>Middle</small>",
        "<small>Right</small>"
    };

    gdouble bath_marks[4] = { 0.0, 33.3, 66.6, 100.0 };
    const gchar *bath_labels[4] = {
        "<span color='blue' size='small'>Cold</span>",
        "<span size='small'>Baby bath</span>",
        "<span size='small'>Hot tub</span>",
        "<span color='Red' size='small'>Hot</span>"
    };

    gdouble pos_marks[4] = { 0.0, 33.3, 66.6, 100.0 };
    const gchar *pos_labels[4] = { "Left", "Right", "Top", "Bottom" };

    gtk_init (&argc, &argv);

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title (GTK_WINDOW (window), "Ranges with marks");
    box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
    flipbox = box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
    gtk_widget_set_hexpand (flipbox, TRUE);
    gtk_widget_set_vexpand (flipbox, TRUE);
    gtk_container_add (GTK_CONTAINER (box1), box);
    gtk_container_add (GTK_CONTAINER (window), box1);

    frame = gtk_frame_new ("No marks");
    scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 100, 1);
    scales = g_slist_prepend (scales, scale);
    gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
    gtk_container_add (GTK_CONTAINER (frame), scale);
    gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);

    frame = gtk_frame_new ("With fill level");
    scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 100, 1);
    scales = g_slist_prepend (scales, scale);
    gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
    gtk_range_set_show_fill_level (GTK_RANGE (scale), TRUE);
    gtk_range_set_fill_level (GTK_RANGE (scale), 50);
    gtk_container_add (GTK_CONTAINER (frame), scale);
    gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);

    frame = gtk_frame_new ("Simple marks");
    extra_scale = scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 100, 1);
    scales = g_slist_prepend (scales, scale);
    gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
    gtk_scale_add_mark (GTK_SCALE (scale), marks[0], GTK_POS_BOTTOM, NULL);
    gtk_scale_add_mark (GTK_SCALE (scale), marks[1], GTK_POS_BOTTOM, NULL);
    gtk_scale_add_mark (GTK_SCALE (scale), marks[2], GTK_POS_BOTTOM, NULL);
    gtk_container_add (GTK_CONTAINER (frame), scale);
    gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);

    frame = gtk_frame_new ("Simple marks up");
    scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 100, 1);
    scales = g_slist_prepend (scales, scale);
    gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
    gtk_scale_add_mark (GTK_SCALE (scale), marks[0], GTK_POS_TOP, NULL);
    gtk_scale_add_mark (GTK_SCALE (scale), marks[1], GTK_POS_TOP, NULL);
    gtk_scale_add_mark (GTK_SCALE (scale), marks[2], GTK_POS_TOP, NULL);
    gtk_container_add (GTK_CONTAINER (frame), scale);
    gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);

    frame = gtk_frame_new ("Labeled marks");
    box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);

    scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 100, 1);
    scales = g_slist_prepend (scales, scale);
    gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
    gtk_scale_add_mark (GTK_SCALE (scale), marks[0], GTK_POS_BOTTOM, labels[0]);
    gtk_scale_add_mark (GTK_SCALE (scale), marks[1], GTK_POS_BOTTOM, labels[1]);
    gtk_scale_add_mark (GTK_SCALE (scale), marks[2], GTK_POS_BOTTOM, labels[2]);
    gtk_container_add (GTK_CONTAINER (frame), scale);
    gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);

    frame = gtk_frame_new ("Some labels");
    scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 100, 1);
    scales = g_slist_prepend (scales, scale);
    gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
    gtk_scale_add_mark (GTK_SCALE (scale), marks[0], GTK_POS_TOP, labels[0]);
    gtk_scale_add_mark (GTK_SCALE (scale), marks[1], GTK_POS_TOP, NULL);
    gtk_scale_add_mark (GTK_SCALE (scale), marks[2], GTK_POS_TOP, labels[2]);
    gtk_container_add (GTK_CONTAINER (frame), scale);
    gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);

    frame = gtk_frame_new ("Above and below");
    scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 100, 1);
    scales = g_slist_prepend (scales, scale);
    gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
    gtk_scale_add_mark (GTK_SCALE (scale), bath_marks[0], GTK_POS_TOP, bath_labels[0]);
    gtk_scale_add_mark (GTK_SCALE (scale), bath_marks[1], GTK_POS_BOTTOM, bath_labels[1]);
    gtk_scale_add_mark (GTK_SCALE (scale), bath_marks[2], GTK_POS_BOTTOM, bath_labels[2]);
    gtk_scale_add_mark (GTK_SCALE (scale), bath_marks[3], GTK_POS_TOP, bath_labels[3]);
    gtk_container_add (GTK_CONTAINER (frame), scale);
    gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);

    frame = gtk_frame_new ("Positions");
    scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 100, 1);
    scales = g_slist_prepend (scales, scale);
    gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
    gtk_scale_add_mark (GTK_SCALE (scale), pos_marks[0], GTK_POS_LEFT, pos_labels[0]);
    gtk_scale_add_mark (GTK_SCALE (scale), pos_marks[1], GTK_POS_RIGHT, pos_labels[1]);
    gtk_scale_add_mark (GTK_SCALE (scale), pos_marks[2], GTK_POS_TOP, pos_labels[2]);
    gtk_scale_add_mark (GTK_SCALE (scale), pos_marks[3], GTK_POS_BOTTOM, pos_labels[3]);
    gtk_container_add (GTK_CONTAINER (frame), scale);
    gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);

    box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_container_add (GTK_CONTAINER (box1), box2);
    button = gtk_button_new_with_label ("Flip");
    g_signal_connect (button, "clicked", G_CALLBACK (flip), NULL);
    gtk_container_add (GTK_CONTAINER (box2), button);

    button = gtk_button_new_with_label ("Invert");
    g_signal_connect (button, "clicked", G_CALLBACK (invert), NULL);
    gtk_container_add (GTK_CONTAINER (box2), button);

    button = gtk_toggle_button_new_with_label ("Trough");
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
    g_signal_connect (button, "toggled", G_CALLBACK (trough), NULL);
    gtk_container_add (GTK_CONTAINER (box2), button);
    gtk_widget_show_all (window);

    button = gtk_toggle_button_new_with_label ("Extra");
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);
    g_signal_connect (button, "toggled", G_CALLBACK (extra), NULL);
    gtk_container_add (GTK_CONTAINER (box2), button);
    gtk_widget_show_all (window);

    gtk_main ();

    return 0;
}
Пример #13
0
/****************************************************************
  Create rates dialog
*****************************************************************/
static GtkWidget *create_rates_dialog(void)
{
  GtkWidget     *shell, *content;
  GtkWidget	*frame, *hgrid;
  int i;

  if (!can_client_issue_orders()) {
    return NULL;
  }
  
  shell = gtk_dialog_new_with_buttons(_("Select tax, luxury and science rates"),
  	NULL,
	0,
	GTK_STOCK_CANCEL,
	GTK_RESPONSE_CANCEL,
	GTK_STOCK_OK,
	GTK_RESPONSE_OK,
	NULL);
  setup_dialog(shell, toplevel);
  gtk_dialog_set_default_response(GTK_DIALOG(shell), GTK_RESPONSE_OK);
  gtk_window_set_position(GTK_WINDOW(shell), GTK_WIN_POS_MOUSE);
  content = gtk_dialog_get_content_area(GTK_DIALOG(shell));

  rates_gov_label = gtk_label_new("");
  gtk_box_pack_start( GTK_BOX( content ), rates_gov_label, TRUE, TRUE, 5 );

  frame = gtk_frame_new( _("Tax") );
  gtk_box_pack_start( GTK_BOX( content ), frame, TRUE, TRUE, 5 );

  hgrid = gtk_grid_new();
  gtk_grid_set_column_spacing(GTK_GRID(hgrid), 10);
  gtk_container_add(GTK_CONTAINER(frame), hgrid);

  rates_tax_scale =
    gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0, 10, 1);
  gtk_range_set_increments(GTK_RANGE(rates_tax_scale), 1, 1);
  for (i = 0; i <= 10; i++) {
    gtk_scale_add_mark(GTK_SCALE(rates_tax_scale), i, GTK_POS_TOP, NULL);
  }
  gtk_widget_set_size_request(rates_tax_scale, 300, 40);
  gtk_scale_set_digits(GTK_SCALE(rates_tax_scale), 0);
  gtk_scale_set_draw_value(GTK_SCALE(rates_tax_scale), FALSE);
  gtk_container_add(GTK_CONTAINER(hgrid), rates_tax_scale);

  rates_tax_label = gtk_label_new("  0%");
  gtk_container_add(GTK_CONTAINER(hgrid), rates_tax_label);
  gtk_widget_set_size_request(rates_tax_label, 40, -1);

  rates_tax_toggle = gtk_check_button_new_with_label( _("Lock") );
  gtk_container_add(GTK_CONTAINER(hgrid), rates_tax_toggle);

  frame = gtk_frame_new( _("Luxury") );
  gtk_box_pack_start( GTK_BOX( content ), frame, TRUE, TRUE, 5 );

  hgrid = gtk_grid_new();
  gtk_grid_set_column_spacing(GTK_GRID(hgrid), 10);
  gtk_container_add(GTK_CONTAINER(frame), hgrid);

  rates_lux_scale =
    gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0, 10, 1);
  gtk_range_set_increments(GTK_RANGE(rates_lux_scale), 1, 1);
  for (i = 0; i <= 10; i++) {
    gtk_scale_add_mark(GTK_SCALE(rates_lux_scale), i, GTK_POS_TOP, NULL);
  }
  gtk_widget_set_size_request(rates_lux_scale, 300, 40);
  gtk_scale_set_digits(GTK_SCALE(rates_lux_scale), 0);
  gtk_scale_set_draw_value(GTK_SCALE(rates_lux_scale), FALSE);
  gtk_container_add(GTK_CONTAINER(hgrid), rates_lux_scale);

  rates_lux_label = gtk_label_new("  0%");
  gtk_container_add(GTK_CONTAINER(hgrid), rates_lux_label);
  gtk_widget_set_size_request(rates_lux_label, 40, -1);

  rates_lux_toggle = gtk_check_button_new_with_label( _("Lock") );
  gtk_container_add(GTK_CONTAINER(hgrid), rates_lux_toggle);

  frame = gtk_frame_new( _("Science") );
  gtk_box_pack_start( GTK_BOX( content ), frame, TRUE, TRUE, 5 );

  hgrid = gtk_grid_new();
  gtk_grid_set_column_spacing(GTK_GRID(hgrid), 10);
  gtk_container_add(GTK_CONTAINER(frame), hgrid);

  rates_sci_scale =
    gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0, 10, 1);
  gtk_range_set_increments(GTK_RANGE(rates_sci_scale), 1, 1);
  for (i = 0; i <= 10; i++) {
    gtk_scale_add_mark(GTK_SCALE(rates_sci_scale), i, GTK_POS_TOP, NULL);
  }
  gtk_widget_set_size_request(rates_sci_scale, 300, 40);
  gtk_scale_set_digits(GTK_SCALE(rates_sci_scale), 0);
  gtk_scale_set_draw_value(GTK_SCALE(rates_sci_scale), FALSE);
  gtk_container_add(GTK_CONTAINER(hgrid), rates_sci_scale);

  rates_sci_label = gtk_label_new("  0%");
  gtk_container_add(GTK_CONTAINER(hgrid), rates_sci_label);
  gtk_widget_set_size_request(rates_sci_label, 40, -1);

  rates_sci_toggle = gtk_check_button_new_with_label( _("Lock") );
  gtk_container_add(GTK_CONTAINER(hgrid), rates_sci_toggle);


  g_signal_connect(shell, "response",
		   G_CALLBACK(rates_command_callback), NULL);
  g_signal_connect(shell, "destroy",
		   G_CALLBACK(gtk_widget_destroyed), &rates_dialog_shell);

  gtk_widget_show_all(content);
  gtk_widget_show_all(gtk_dialog_get_action_area(GTK_DIALOG(shell)));

  rates_tax_value=-1;
  rates_lux_value=-1;
  rates_sci_value=-1;

  rates_tax_sig =
    g_signal_connect_after(rates_tax_scale, "value-changed",
			   G_CALLBACK(rates_changed_callback), NULL);

  rates_lux_sig =
    g_signal_connect_after(rates_lux_scale, "value-changed",
			   G_CALLBACK(rates_changed_callback), NULL);

  rates_sci_sig =
    g_signal_connect_after(rates_sci_scale, "value-changed",
			   G_CALLBACK(rates_changed_callback), NULL);

  rates_set_values(client.conn.playing->economic.tax, 0,
		   client.conn.playing->economic.luxury, 0,
		   client.conn.playing->economic.science, 0);
  return shell;
}
Пример #14
0
int main (int argc, char *argv[])
{
  GtkWidget *window;
  GtkWidget *box;
  GtkWidget *box2;
  GtkWidget *frame;
  GtkWidget *scale;
  GtkWidget *toggle;
  gdouble marks[3] = { 0.0, 50.0, 100.0 };
  const gchar *labels[3] = { 
    "<small>Left</small>", 
    "<small>Middle</small>", 
    "<small>Right</small>" 
  };

  gdouble bath_marks[4] = { 0.0, 33.3, 66.6, 100.0 };
  const gchar *bath_labels[4] = { 
    "<span color='blue' size='small'>Cold</span>", 
    "<span size='small'>Baby bath</span>", 
    "<span size='small'>Hot tub</span>", 
    "<span color='Red' size='small'>Hot</span>" 
  };

  gdouble pos_marks[4] = { 0.0, 33.3, 66.6, 100.0 };
  const gchar *pos_labels[4] = { "Left", "Right", "Top", "Bottom" };

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Ranges with marks");
  box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);

  frame = gtk_frame_new ("No marks");
  scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
                                    0, 100, 1);
  gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
  gtk_container_add (GTK_CONTAINER (frame), scale);
  gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);

  frame = gtk_frame_new ("Simple marks");
  scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
                                    0, 100, 1);
  gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
  gtk_scale_add_mark (GTK_SCALE (scale), marks[0], GTK_POS_BOTTOM, NULL);
  gtk_scale_add_mark (GTK_SCALE (scale), marks[1], GTK_POS_BOTTOM, NULL);
  gtk_scale_add_mark (GTK_SCALE (scale), marks[2], GTK_POS_BOTTOM, NULL);
  gtk_container_add (GTK_CONTAINER (frame), scale);
  gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);
 
  frame = gtk_frame_new ("Labeled marks");
  scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
                                    0, 100, 1);
  gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
  gtk_scale_add_mark (GTK_SCALE (scale), marks[0], GTK_POS_BOTTOM, labels[0]);
  gtk_scale_add_mark (GTK_SCALE (scale), marks[1], GTK_POS_BOTTOM, labels[1]);
  gtk_scale_add_mark (GTK_SCALE (scale), marks[2], GTK_POS_BOTTOM, labels[2]);
  gtk_container_add (GTK_CONTAINER (frame), scale);
  gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);
  
  frame = gtk_frame_new ("Some labels");
  scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
                                    0, 100, 1);
  gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
  gtk_scale_add_mark (GTK_SCALE (scale), marks[0], GTK_POS_BOTTOM, labels[0]);
  gtk_scale_add_mark (GTK_SCALE (scale), marks[1], GTK_POS_BOTTOM, NULL);
  gtk_scale_add_mark (GTK_SCALE (scale), marks[2], GTK_POS_BOTTOM, labels[2]);
  gtk_container_add (GTK_CONTAINER (frame), scale);
  gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);
  
  frame = gtk_frame_new ("Above and below");
  scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
                                    0, 100, 1);
  gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
  gtk_scale_add_mark (GTK_SCALE (scale), bath_marks[0], GTK_POS_TOP, bath_labels[0]);
  gtk_scale_add_mark (GTK_SCALE (scale), bath_marks[1], GTK_POS_BOTTOM, bath_labels[1]);
  gtk_scale_add_mark (GTK_SCALE (scale), bath_marks[2], GTK_POS_BOTTOM, bath_labels[2]);
  gtk_scale_add_mark (GTK_SCALE (scale), bath_marks[3], GTK_POS_TOP, bath_labels[3]);
  gtk_container_add (GTK_CONTAINER (frame), scale);
  gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);

  frame = gtk_frame_new ("Positions");
  scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
                                    0, 100, 1);
  gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
  gtk_scale_add_mark (GTK_SCALE (scale), pos_marks[0], GTK_POS_LEFT, pos_labels[0]);
  gtk_scale_add_mark (GTK_SCALE (scale), pos_marks[1], GTK_POS_RIGHT, pos_labels[1]);
  gtk_scale_add_mark (GTK_SCALE (scale), pos_marks[2], GTK_POS_TOP, pos_labels[2]);
  gtk_scale_add_mark (GTK_SCALE (scale), pos_marks[3], GTK_POS_BOTTOM, pos_labels[3]);
  gtk_container_add (GTK_CONTAINER (frame), scale);
  gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);

  frame = gtk_frame_new ("Show/hide trough");
  box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
  scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
                                    0, 100, 1);
  gtk_box_pack_start (GTK_BOX (box2), scale, TRUE, TRUE, 0);
  toggle = gtk_toggle_button_new_with_label ("Show slider trough");
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), TRUE);
  g_signal_connect (G_OBJECT (toggle), "toggled",
                    G_CALLBACK (show_trough_toggled), scale);
  gtk_box_pack_start (GTK_BOX (box2), toggle, TRUE, TRUE, 0);
  gtk_container_add (GTK_CONTAINER (frame), box2);
  gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);

  box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
  gtk_box_pack_start (GTK_BOX (box), box2, TRUE, TRUE, 0);

  frame = gtk_frame_new ("No marks");
  scale = gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL,
                                    0, 100, 1);
  gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
  gtk_container_add (GTK_CONTAINER (frame), scale);
  gtk_box_pack_start (GTK_BOX (box2), frame, FALSE, FALSE, 0);

  frame = gtk_frame_new ("Simple marks");
  scale = gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL,
                                    0, 100, 1);
  gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
  gtk_scale_add_mark (GTK_SCALE (scale), marks[0], GTK_POS_LEFT, NULL);
  gtk_scale_add_mark (GTK_SCALE (scale), marks[1], GTK_POS_LEFT, NULL);
  gtk_scale_add_mark (GTK_SCALE (scale), marks[2], GTK_POS_LEFT, NULL);
  gtk_container_add (GTK_CONTAINER (frame), scale);
  gtk_box_pack_start (GTK_BOX (box2), frame, FALSE, FALSE, 0);
 
  frame = gtk_frame_new ("Labeled marks");
  scale = gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL,
                                    0, 100, 1);
  gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
  gtk_scale_add_mark (GTK_SCALE (scale), marks[0], GTK_POS_LEFT, labels[0]);
  gtk_scale_add_mark (GTK_SCALE (scale), marks[1], GTK_POS_LEFT, labels[1]);
  gtk_scale_add_mark (GTK_SCALE (scale), marks[2], GTK_POS_LEFT, labels[2]);
  gtk_container_add (GTK_CONTAINER (frame), scale);
  gtk_box_pack_start (GTK_BOX (box2), frame, FALSE, FALSE, 0);
  
  frame = gtk_frame_new ("Some labels");
  scale = gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL,
                                    0, 100, 1);
  gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
  gtk_scale_add_mark (GTK_SCALE (scale), marks[0], GTK_POS_LEFT, labels[0]);
  gtk_scale_add_mark (GTK_SCALE (scale), marks[1], GTK_POS_LEFT, NULL);
  gtk_scale_add_mark (GTK_SCALE (scale), marks[2], GTK_POS_LEFT, labels[2]);
  gtk_container_add (GTK_CONTAINER (frame), scale);
  gtk_box_pack_start (GTK_BOX (box2), frame, FALSE, FALSE, 0);
  
  frame = gtk_frame_new ("Right and left");
  scale = gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL,
                                    0, 100, 1);
  gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
  gtk_scale_add_mark (GTK_SCALE (scale), bath_marks[0], GTK_POS_RIGHT, bath_labels[0]);
  gtk_scale_add_mark (GTK_SCALE (scale), bath_marks[1], GTK_POS_LEFT, bath_labels[1]);
  gtk_scale_add_mark (GTK_SCALE (scale), bath_marks[2], GTK_POS_LEFT, bath_labels[2]);
  gtk_scale_add_mark (GTK_SCALE (scale), bath_marks[3], GTK_POS_RIGHT, bath_labels[3]);
  gtk_container_add (GTK_CONTAINER (frame), scale);
  gtk_box_pack_start (GTK_BOX (box2), frame, FALSE, FALSE, 0);

  frame = gtk_frame_new ("Positions");
  scale = gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL,
                                    0, 100, 1);
  gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
  gtk_scale_add_mark (GTK_SCALE (scale), pos_marks[0], GTK_POS_LEFT, pos_labels[0]);
  gtk_scale_add_mark (GTK_SCALE (scale), pos_marks[1], GTK_POS_RIGHT, pos_labels[1]);
  gtk_scale_add_mark (GTK_SCALE (scale), pos_marks[2], GTK_POS_TOP, pos_labels[2]);
  gtk_scale_add_mark (GTK_SCALE (scale), pos_marks[3], GTK_POS_BOTTOM, pos_labels[3]);
  gtk_container_add (GTK_CONTAINER (frame), scale);
  gtk_box_pack_start (GTK_BOX (box2), frame, FALSE, FALSE, 0);

  gtk_container_add (GTK_CONTAINER (window), box);
  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}
Пример #15
0
void DisplayDialog()
{
    int return_value;

    GtkWidget *dialog;
    GtkWidget *main_frame, *main_box;

    GtkWidget *mixing_frame, *mixing_box;
    GtkWidget *int_label, *int_box;
    GtkWidget *effects_check;
    GtkWidget *dealias_filter;
    GtkWidget *debug_check;
    GtkWidget *debug_button;

    GtkWidget *output_frame, *output_box;
    GtkWidget *mod_label, *mod_box;
    GtkWidget *api_label, *api_box;
#if SDL_MAJOR_VERSION >= 2
    GtkWidget *sdl_api_label, *sdl_api_box;
#endif
    GtkWidget *latency_label, *latency_slide;
    GtkWidget *sync_label, *sync_box;
    GtkWidget *advanced_button;

    /* Create the widgets */
    dialog = gtk_dialog_new_with_buttons(
        "SPU2-X Config",
        NULL, /* parent window*/
        (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
        "OK", GTK_RESPONSE_ACCEPT,
        "Cancel", GTK_RESPONSE_REJECT,
        NULL);

    int_label = gtk_label_new("Interpolation:");
    int_box = gtk_combo_box_text_new();
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(int_box), "0 - Nearest (fastest/bad quality)");
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(int_box), "1 - Linear (simple/okay sound)");
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(int_box), "2 - Cubic (artificial highs)");
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(int_box), "3 - Hermite (better highs)");
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(int_box), "4 - Catmull-Rom (PS2-like/slow)");
    gtk_combo_box_set_active(GTK_COMBO_BOX(int_box), Interpolation);

    effects_check = gtk_check_button_new_with_label("Disable Effects Processing");
    dealias_filter = gtk_check_button_new_with_label("Use the de-alias filter (overemphasizes the highs)");

    debug_check = gtk_check_button_new_with_label("Enable Debug Options");
    debug_button = gtk_button_new_with_label("Debug...");

    mod_label = gtk_label_new("Module:");
    mod_box = gtk_combo_box_text_new();
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(mod_box), "0 - No Sound (emulate SPU2 only)");
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(mod_box), "1 - PortAudio (cross-platform)");
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(mod_box), "2 - SDL Audio (recommended for PulseAudio)");
    //gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(mod_box), "3 - Alsa (probably doesn't work)");
    gtk_combo_box_set_active(GTK_COMBO_BOX(mod_box), OutputModule);

    api_label = gtk_label_new("PortAudio API:");
    api_box = gtk_combo_box_text_new();
#ifdef __linux__
    // In order to keep it the menu light, I only put linux major api
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(api_box), "0 - ALSA (recommended)");
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(api_box), "1 - OSS (legacy)");
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(api_box), "2 - JACK");
#else
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(api_box), "OSS");
#endif
    gtk_combo_box_set_active(GTK_COMBO_BOX(api_box), OutputAPI);

#if SDL_MAJOR_VERSION >= 2
    sdl_api_label = gtk_label_new("SDL API:");
    sdl_api_box = gtk_combo_box_text_new();
    // YES It sucks ...
    for (int i = 0; i < SDL_GetNumAudioDrivers(); ++i) {
        gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(sdl_api_box), SDL_GetAudioDriver(i));
    }
    gtk_combo_box_set_active(GTK_COMBO_BOX(sdl_api_box), SdlOutputAPI);
#endif

    latency_label = gtk_label_new("Latency:");
    const int min_latency = SynchMode == 0 ? LATENCY_MIN_TIMESTRETCH : LATENCY_MIN;
#if GTK_MAJOR_VERSION < 3
    latency_slide = gtk_hscale_new_with_range(min_latency, LATENCY_MAX, 5);
#else
    latency_slide = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, min_latency, LATENCY_MAX, 5);
#endif
    gtk_range_set_value(GTK_RANGE(latency_slide), SndOutLatencyMS);

    sync_label = gtk_label_new("Synchronization Mode:");
    sync_box = gtk_combo_box_text_new();
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(sync_box), "TimeStretch (Recommended)");
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(sync_box), "Async Mix (Breaks some games!)");
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(sync_box), "None (Audio can skip.)");
    gtk_combo_box_set_active(GTK_COMBO_BOX(sync_box), SynchMode);

    advanced_button = gtk_button_new_with_label("Advanced...");

#if GTK_MAJOR_VERSION < 3
    main_box = gtk_hbox_new(false, 5);
#else
    main_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
#endif
    main_frame = gtk_frame_new("SPU2-X Config");
    gtk_container_add(GTK_CONTAINER(main_frame), main_box);

#if GTK_MAJOR_VERSION < 3
    mixing_box = gtk_vbox_new(false, 5);
#else
    mixing_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
#endif
    mixing_frame = gtk_frame_new("Mixing Settings:");
    gtk_container_add(GTK_CONTAINER(mixing_frame), mixing_box);

#if GTK_MAJOR_VERSION < 3
    output_box = gtk_vbox_new(false, 5);
#else
    output_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
#endif
    output_frame = gtk_frame_new("Output Settings:");
    gtk_container_add(GTK_CONTAINER(output_frame), output_box);

    gtk_container_add(GTK_CONTAINER(mixing_box), int_label);
    gtk_container_add(GTK_CONTAINER(mixing_box), int_box);
    gtk_container_add(GTK_CONTAINER(mixing_box), effects_check);
    gtk_container_add(GTK_CONTAINER(mixing_box), dealias_filter);
    gtk_container_add(GTK_CONTAINER(mixing_box), debug_check);
    gtk_container_add(GTK_CONTAINER(mixing_box), debug_button);

    gtk_container_add(GTK_CONTAINER(output_box), mod_label);
    gtk_container_add(GTK_CONTAINER(output_box), mod_box);
    gtk_container_add(GTK_CONTAINER(output_box), api_label);
    gtk_container_add(GTK_CONTAINER(output_box), api_box);
#if SDL_MAJOR_VERSION >= 2
    gtk_container_add(GTK_CONTAINER(output_box), sdl_api_label);
    gtk_container_add(GTK_CONTAINER(output_box), sdl_api_box);
#endif
    gtk_container_add(GTK_CONTAINER(output_box), sync_label);
    gtk_container_add(GTK_CONTAINER(output_box), sync_box);
    gtk_container_add(GTK_CONTAINER(output_box), latency_label);
    gtk_container_add(GTK_CONTAINER(output_box), latency_slide);
    gtk_container_add(GTK_CONTAINER(output_box), advanced_button);

    gtk_container_add(GTK_CONTAINER(main_box), mixing_frame);
    gtk_container_add(GTK_CONTAINER(main_box), output_frame);

    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(effects_check), EffectsDisabled);
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dealias_filter), postprocess_filter_dealias);
    //FinalVolume;
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(debug_check), DebugEnabled);

    gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_frame);
    gtk_widget_show_all(dialog);

    g_signal_connect(sync_box, "changed", G_CALLBACK(cb_adjust_latency), latency_slide);
    g_signal_connect_swapped(advanced_button, "clicked", G_CALLBACK(advanced_dialog), advanced_button);
    g_signal_connect_swapped(debug_button, "clicked", G_CALLBACK(debug_dialog), debug_button);

    return_value = gtk_dialog_run(GTK_DIALOG(dialog));

    if (return_value == GTK_RESPONSE_ACCEPT) {
        DebugEnabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(debug_check));
        postprocess_filter_dealias = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dealias_filter));
        if (gtk_combo_box_get_active(GTK_COMBO_BOX(int_box)) != -1)
            Interpolation = gtk_combo_box_get_active(GTK_COMBO_BOX(int_box));

        EffectsDisabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(effects_check));
        //FinalVolume;

        if (gtk_combo_box_get_active(GTK_COMBO_BOX(mod_box)) != -1)
            OutputModule = gtk_combo_box_get_active(GTK_COMBO_BOX(mod_box));

        if (gtk_combo_box_get_active(GTK_COMBO_BOX(api_box)) != -1) {
            OutputAPI = gtk_combo_box_get_active(GTK_COMBO_BOX(api_box));
#ifdef __linux__
            switch (OutputAPI) {
                case 0:
                    PortaudioOut->SetApiSettings(L"ALSA");
                    break;
                case 1:
                    PortaudioOut->SetApiSettings(L"OSS");
                    break;
                case 2:
                    PortaudioOut->SetApiSettings(L"JACK");
                    break;
                default:
                    PortaudioOut->SetApiSettings(L"Unknown");
            }
#else
            switch (OutputAPI) {
                case 0:
                    PortaudioOut->SetApiSettings(L"OSS");
                    break;
                default:
                    PortaudioOut->SetApiSettings(L"Unknown");
            }
#endif
        }

#if SDL_MAJOR_VERSION >= 2
        if (gtk_combo_box_get_active(GTK_COMBO_BOX(sdl_api_box)) != -1) {
            SdlOutputAPI = gtk_combo_box_get_active(GTK_COMBO_BOX(sdl_api_box));
            // YES It sucks ...
            SDLOut->SetApiSettings(wxString(SDL_GetAudioDriver(SdlOutputAPI), wxConvUTF8));
        }
#endif

        SndOutLatencyMS = gtk_range_get_value(GTK_RANGE(latency_slide));

        if (gtk_combo_box_get_active(GTK_COMBO_BOX(sync_box)) != -1)
            SynchMode = gtk_combo_box_get_active(GTK_COMBO_BOX(sync_box));
    }

    gtk_widget_destroy(dialog);
}
Пример #16
0
/* This creates all the GTK+ widgets that compose our application, and registers the callbacks */
static GtkWidget* create_player_ui (CustomData *data, guint decknumber) {
    GtkWidget *stop_button; /* Buttons */
    GtkWidget *title;
    GtkWidget *myGrid;


    myGrid = gtk_grid_new();

    data->playPauseButton = _create_media_button (GTK_STOCK_MEDIA_PAUSE);
    g_signal_connect (G_OBJECT (data->playPauseButton), "clicked", G_CALLBACK (playpause_cb), data);

    stop_button = _create_media_button (GTK_STOCK_MEDIA_STOP);
    g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb), data);

    data->slider = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 100, 1);
    gtk_scale_set_draw_value (GTK_SCALE (data->slider), 0);
    data->slider_update_signal_id = g_signal_connect (G_OBJECT (data->slider), "value-changed", G_CALLBACK (slider_cb), data);
    g_signal_connect (G_OBJECT (data->slider), "move-slider", G_CALLBACK (slider_cb), data);

    data->timelabel = gtk_label_new ("");
    update_timelabel(data, "Time remaining");
    data->taglabel = gtk_label_new ("Selected filename");
    {
        data->filechooser = gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_OPEN);
        gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (data->filechooser), TRUE);
        gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (data->filechooser), FALSE);
        gtk_file_chooser_set_use_preview_label (GTK_FILE_CHOOSER (data->filechooser), FALSE);

        if (NULL != data->last_folder_uri) {
            gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (data->filechooser),
                    data->last_folder_uri);
        } else {
            gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (data->filechooser),
                    g_get_home_dir());
        }

        GtkFileFilter *filter = gtk_file_filter_new();

        gtk_file_filter_add_mime_type (filter, "audio/*");
        gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (data->filechooser), filter);

        data->file_selection_signal_id = 
            g_signal_connect (G_OBJECT (data->filechooser), "selection-changed", G_CALLBACK (file_selection_cb), data);

        /* block signal to prevent false selection on startup*/
        g_signal_handler_block (data->filechooser, data->file_selection_signal_id);
    }

    {
        gchar *titlename = g_strdup_printf ("Deck %u\n", decknumber + 1);
        title = gtk_label_new (titlename);
        g_free (titlename);
    }


    /* arrange all elements into myGrid */
    gtk_grid_attach (GTK_GRID (myGrid), data->filechooser, 0, 0, 1, 3);
    gtk_grid_attach_next_to (GTK_GRID (myGrid), title, data->filechooser, GTK_POS_TOP, 1, 3);
    gtk_grid_attach_next_to (GTK_GRID (myGrid), data->playPauseButton, data->filechooser, GTK_POS_RIGHT, 1, 1);
    gtk_grid_attach_next_to (GTK_GRID (myGrid), stop_button, data->playPauseButton, GTK_POS_BOTTOM, 1, 1);

    gtk_grid_attach_next_to (GTK_GRID (myGrid), data->taglabel, data->filechooser, GTK_POS_BOTTOM, 2, 1);
    gtk_grid_attach_next_to (GTK_GRID (myGrid), data->timelabel, data->taglabel, GTK_POS_BOTTOM, 2, 1);

    gtk_grid_attach_next_to (GTK_GRID (myGrid), data->slider, data->timelabel, GTK_POS_BOTTOM, 2, 1);


    /* allow at least one expanding child, so all uppper widgets will resize
     * when maximising the window
     */
    gtk_widget_set_hexpand (data->filechooser, TRUE);
    gtk_widget_set_vexpand (data->filechooser, TRUE);

    gtk_label_set_line_wrap(GTK_LABEL (data->taglabel), TRUE);

    return myGrid;
}
Пример #17
0
static void
gst_switch_ptz_init (GstSwitchPTZ * ptz)
{
  GtkWidget *box_main, *box_video, *box_control;
  GtkWidget *box_control_pan, *box_control_tilt, *box_control_zoom;
  GtkWidget *scale_pan, *scale_tilt, *control_grid, *box_buttons_tilt;
  GtkWidget *control_buttons[3][3] = { {NULL} };
  GtkWidget *box_zoom, *zoom_minus, *zoom_reset, *zoom_plus;
  GtkWidget *scrollwin;
  GtkWidget *scale_zoom;
  GtkWidget *scale_pan_speed, *scale_tilt_speed, *scale_zoom_speed;
  GtkWidget *label_pan_speed, *label_tilt_speed, *label_zoom_speed;
  GtkWidget *label;
  const gchar *control_labels[3][3] = {
    /*
       {"  \\  ", "  ^  ", "  /  "},
       {"  <  ", "  *  ", "  >  "},
       {"  /  ", "  v  ", "  \\  "},
     */
    /*
       { "  \\  ", GTK_STOCK_GO_UP, "  /  " },
       { GTK_STOCK_GO_BACK, GTK_STOCK_HOME, GTK_STOCK_GO_FORWARD },
       { "  /  ", GTK_STOCK_GO_DOWN, "  \\  " },
     */
    {"icons/up_left.png", "icons/up.png", "icons/up_right.png"},
    {"icons/left.png", "icons/center.png", "icons/right.png"},
    {"icons/down_left.png", "icons/down.png", "icons/down_right.png"},
  };
  int n, m;
  const char *title = NULL;

  ptz->controller = gst_cam_controller_new (ptz_control_protocol);
  if (ptz->controller == NULL) {
    return;
  }

  gst_cam_controller_open (ptz->controller, ptz_device_name);
  title = ptz->controller->device_info;
  if (title == NULL)
    title = "??? - PTZ Controller";

  ptz->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (ptz->window), 640, 480);
  gtk_window_set_title (GTK_WINDOW (ptz->window), title);
  g_signal_connect (G_OBJECT (ptz->window), "delete-event",
      G_CALLBACK (gst_switch_ptz_window_closed), ptz);

  box_main = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
  box_video = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
  box_control = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);

  scrollwin = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin),
      GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
  gtk_widget_set_size_request (scrollwin, 200, -1);
  gtk_widget_set_vexpand (scrollwin, TRUE);
  gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrollwin),
      box_control);

  gtk_box_pack_start (GTK_BOX (box_main), box_video, TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (box_main), scrollwin, FALSE, TRUE, 0);
  gtk_container_add (GTK_CONTAINER (ptz->window), box_main);
  gtk_container_set_border_width (GTK_CONTAINER (ptz->window), 5);

  ptz->video_view = gtk_drawing_area_new ();
  gtk_widget_set_name (ptz->video_view, "video");
  gtk_widget_set_double_buffered (ptz->video_view, FALSE);
  gtk_widget_set_hexpand (ptz->video_view, TRUE);
  gtk_widget_set_vexpand (ptz->video_view, TRUE);
  gtk_widget_set_events (ptz->video_view, GDK_EXPOSURE_MASK
      | GDK_LEAVE_NOTIFY_MASK
      | GDK_BUTTON_PRESS_MASK
      | GDK_BUTTON_RELEASE_MASK
      | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK);
  gtk_box_pack_start (GTK_BOX (box_video), ptz->video_view, TRUE, TRUE, 0);

  scale_pan =
      gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
      ptz->controller->pan_min, ptz->controller->pan_max, 1.0);
  scale_tilt =
      gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL,
      ptz->controller->tilt_min, ptz->controller->tilt_max, 1.0);
  //gtk_range_set_slider_size_fixed (GTK_RANGE (scale_pan), TRUE);
  gtk_widget_set_size_request (scale_pan, 300, -1);
  gtk_scale_set_value_pos (GTK_SCALE (scale_pan), GTK_POS_RIGHT);
  gtk_scale_set_value_pos (GTK_SCALE (scale_tilt), GTK_POS_BOTTOM);
  gtk_range_set_inverted (GTK_RANGE (scale_tilt), TRUE);
  ptz->adjust_pan = gtk_range_get_adjustment (GTK_RANGE (scale_pan));
  ptz->adjust_tilt = gtk_range_get_adjustment (GTK_RANGE (scale_tilt));
  g_signal_connect (gtk_range_get_adjustment (GTK_RANGE (scale_pan)),
      "value-changed", G_CALLBACK (gst_switch_ptz_pan_changed), ptz);
  g_signal_connect (gtk_range_get_adjustment (GTK_RANGE (scale_tilt)),
      "value-changed", G_CALLBACK (gst_switch_ptz_tilt_changed), ptz);

  control_grid = gtk_grid_new ();
  gtk_grid_insert_row (GTK_GRID (control_grid), 0);
  gtk_grid_insert_row (GTK_GRID (control_grid), 1);
  gtk_grid_insert_row (GTK_GRID (control_grid), 2);
  gtk_grid_insert_column (GTK_GRID (control_grid), 0);
  gtk_grid_insert_column (GTK_GRID (control_grid), 1);
  gtk_grid_insert_column (GTK_GRID (control_grid), 2);
  for (n = 0; n < 3; ++n) {
    for (m = 0; m < 3; ++m) {
      GtkWidget *btn = control_buttons[m][n] = gtk_button_new ();
      gtk_grid_attach (GTK_GRID (control_grid), btn, n, m, 1, 1);
      gtk_widget_set_size_request (btn, 70, 70);
      gtk_button_set_image (GTK_BUTTON (btn),
          gtk_image_new_from_file (control_labels[m][n]));
    }
  }

  label = gtk_label_new ("");
  gtk_label_set_markup (GTK_LABEL (label), "<b>Pan/Tilt:</b>");
  box_buttons_tilt = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  gtk_box_pack_start (GTK_BOX (box_control), label, TRUE, TRUE, 1);
  gtk_box_pack_start (GTK_BOX (box_control), scale_pan, FALSE, TRUE, 10);
  gtk_box_pack_start (GTK_BOX (box_buttons_tilt), scale_tilt, FALSE, TRUE, 10);
  gtk_box_pack_start (GTK_BOX (box_buttons_tilt), control_grid, FALSE, TRUE,
      10);
  gtk_box_pack_start (GTK_BOX (box_control), box_buttons_tilt, FALSE, TRUE, 10);
  gtk_box_pack_start (GTK_BOX (box_control), gtk_label_new (""), TRUE, TRUE,
      10);

  box_zoom = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  zoom_minus = gtk_button_new ();
  zoom_reset = gtk_button_new ();
  zoom_plus = gtk_button_new ();
  gtk_button_set_image (GTK_BUTTON (zoom_minus),
      gtk_image_new_from_file ("icons/zoom_out.png"));
  gtk_button_set_image (GTK_BUTTON (zoom_reset),
      gtk_image_new_from_file ("icons/zoom.png"));
  gtk_button_set_image (GTK_BUTTON (zoom_plus),
      gtk_image_new_from_file ("icons/zoom_in.png"));
  gtk_widget_set_size_request (zoom_minus, 70, 70);
  gtk_widget_set_size_request (zoom_reset, 70, 70);
  gtk_widget_set_size_request (zoom_plus, 70, 70);

  label = gtk_label_new ("");
  gtk_label_set_markup (GTK_LABEL (label), "<b>Zoom:</b>");
  gtk_box_pack_start (GTK_BOX (box_control), label, TRUE, TRUE, 1);
  gtk_box_pack_start (GTK_BOX (box_zoom), gtk_label_new (""), TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (box_zoom), zoom_minus, FALSE, FALSE, 5);
  gtk_box_pack_start (GTK_BOX (box_zoom), zoom_reset, FALSE, FALSE, 5);
  gtk_box_pack_start (GTK_BOX (box_zoom), zoom_plus, FALSE, FALSE, 5);
  gtk_box_pack_start (GTK_BOX (box_zoom), gtk_label_new (""), TRUE, TRUE, 10);

  scale_zoom =
      gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 1.0, 0.01);
  gtk_range_set_value (GTK_RANGE (scale_zoom), 0.5);
  ptz->adjust_zoom = gtk_range_get_adjustment (GTK_RANGE (scale_zoom));
  label = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  gtk_box_pack_start (GTK_BOX (label), scale_zoom, TRUE, TRUE, 10);
  gtk_box_pack_start (GTK_BOX (box_control), label, TRUE, TRUE, 5);
  gtk_box_pack_start (GTK_BOX (box_control), box_zoom, TRUE, TRUE, 5);
  gtk_box_pack_start (GTK_BOX (box_control), gtk_label_new (""), TRUE, TRUE,
      10);

  g_signal_connect (zoom_minus, "pressed",
      G_CALLBACK (gst_switch_ptz_button_pressed_zoom_minus), ptz);
  g_signal_connect (zoom_reset, "pressed",
      G_CALLBACK (gst_switch_ptz_button_pressed_zoom_reset), ptz);
  g_signal_connect (zoom_plus, "pressed",
      G_CALLBACK (gst_switch_ptz_button_pressed_zoom_plus), ptz);

  g_signal_connect (zoom_minus, "released",
      G_CALLBACK (gst_switch_ptz_button_released_zoom_minus), ptz);
  g_signal_connect (zoom_plus, "released",
      G_CALLBACK (gst_switch_ptz_button_released_zoom_plus), ptz);


  scale_pan_speed =
      gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
      ptz->controller->pan_speed_min, ptz->controller->pan_speed_max, 1.0);
  scale_tilt_speed =
      gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
      ptz->controller->tilt_speed_min, ptz->controller->tilt_speed_max, 1.0);
  scale_zoom_speed =
      gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 1.0, 0.01);
  gtk_range_set_value (GTK_RANGE (scale_pan_speed),
      ptz->controller->pan_speed_max);
  gtk_range_set_value (GTK_RANGE (scale_tilt_speed),
      ptz->controller->tilt_speed_max);
  gtk_range_set_value (GTK_RANGE (scale_zoom_speed), 1.0);

  ptz->adjust_pan_speed =
      gtk_range_get_adjustment (GTK_RANGE (scale_pan_speed));
  ptz->adjust_tilt_speed =
      gtk_range_get_adjustment (GTK_RANGE (scale_tilt_speed));
  ptz->adjust_zoom_speed =
      gtk_range_get_adjustment (GTK_RANGE (scale_zoom_speed));
  label_pan_speed = gtk_label_new ("");
  label_tilt_speed = gtk_label_new ("");
  label_zoom_speed = gtk_label_new ("");
  gtk_label_set_markup (GTK_LABEL (label_pan_speed), "<b>P:</b>");
  gtk_label_set_markup (GTK_LABEL (label_tilt_speed), "<b>T:</b>");
  gtk_label_set_markup (GTK_LABEL (label_zoom_speed), "<b>Z:</b>");
  box_control_pan = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  box_control_tilt = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  box_control_zoom = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

  label = gtk_label_new ("");
  gtk_label_set_markup (GTK_LABEL (label), "<b>Speeds:</b>");
  gtk_box_pack_start (GTK_BOX (box_control), label, FALSE, TRUE, 1);
  gtk_box_pack_start (GTK_BOX (box_control_pan), label_pan_speed, FALSE, FALSE,
      0);
  gtk_box_pack_start (GTK_BOX (box_control_pan), scale_pan_speed, TRUE, TRUE,
      10);
  gtk_box_pack_start (GTK_BOX (box_control_tilt), label_tilt_speed, FALSE,
      FALSE, 0);
  gtk_box_pack_start (GTK_BOX (box_control_tilt), scale_tilt_speed, TRUE, TRUE,
      10);
  gtk_box_pack_start (GTK_BOX (box_control_zoom), label_zoom_speed, FALSE,
      FALSE, 0);
  gtk_box_pack_start (GTK_BOX (box_control_zoom), scale_zoom_speed, TRUE, TRUE,
      10);

  gtk_box_pack_start (GTK_BOX (box_control), box_control_pan, FALSE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (box_control), box_control_tilt, FALSE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (box_control), box_control_zoom, FALSE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (box_control), gtk_label_new (""), TRUE, TRUE,
      10);

  {
    double v, tick = 50;
    gchar *s;
    gchar buf[64] = { 0 };
    int n;
    const gchar *fmt = "<small><sub>%d</sub></small>";
    const gchar *fmtb = "<small><sub><b>%d</b></sub></small>";
    g_sprintf ((s = buf), fmtb, 0);
    gtk_scale_add_mark (GTK_SCALE (scale_pan), 0, GTK_POS_BOTTOM, s);
    g_sprintf ((s = buf), fmtb, (int) ptz->controller->pan_min);
    gtk_scale_add_mark (GTK_SCALE (scale_pan), ptz->controller->pan_min,
        GTK_POS_BOTTOM, s);
    g_sprintf ((s = buf), fmtb, (int) ptz->controller->pan_max);
    gtk_scale_add_mark (GTK_SCALE (scale_pan), ptz->controller->pan_max,
        GTK_POS_BOTTOM, s);
    g_sprintf ((s = buf), fmtb, 0);
    gtk_scale_add_mark (GTK_SCALE (scale_tilt), 0, GTK_POS_RIGHT, s);
    g_sprintf ((s = buf), fmtb, (int) ptz->controller->tilt_min);
    gtk_scale_add_mark (GTK_SCALE (scale_tilt), ptz->controller->tilt_min,
        GTK_POS_RIGHT, s);
    g_sprintf ((s = buf), fmtb, (int) ptz->controller->tilt_max);
    gtk_scale_add_mark (GTK_SCALE (scale_tilt), ptz->controller->tilt_max,
        GTK_POS_RIGHT, s);
    for (v = -tick; ptz->controller->pan_min <= v; v -= tick) {
      if (v - ptz->controller->pan_min < 1)
        continue;
      n = (int) v;
      s = NULL;
      if (abs (n) % 50 == 0)
        g_sprintf ((s = buf), fmt, n);
      gtk_scale_add_mark (GTK_SCALE (scale_pan), v, GTK_POS_BOTTOM, s);
    }
    for (v = tick; v <= ptz->controller->pan_max; v += tick) {
      if (ptz->controller->pan_max - v < 1)
        continue;
      n = (int) v;
      s = NULL;
      if (abs (n) % 50 == 0)
        g_sprintf ((s = buf), fmt, n);
      gtk_scale_add_mark (GTK_SCALE (scale_pan), v, GTK_POS_BOTTOM, s);
    }
    for (v = -tick; ptz->controller->tilt_min <= v; v -= tick) {
      if (v - ptz->controller->tilt_min < 1)
        continue;
      n = (int) v;
      s = NULL;
      if (abs (n) % 50 == 0)
        g_sprintf ((s = buf), fmt, n);
      gtk_scale_add_mark (GTK_SCALE (scale_tilt), v, GTK_POS_RIGHT, s);
    }
    for (v = tick; v <= ptz->controller->tilt_max; v += tick) {
      if (ptz->controller->tilt_max - v < 1)
        continue;
      n = (int) v;
      s = NULL;
      if (abs (n) % 50 == 0)
        g_sprintf ((s = buf), fmt, n);
      gtk_scale_add_mark (GTK_SCALE (scale_tilt), v, GTK_POS_RIGHT, s);
    }

    g_sprintf ((s = buf), fmtb, (int) (v =
            ptz->controller->pan_speed_min + 0.5));
    gtk_scale_add_mark (GTK_SCALE (scale_pan_speed), v, GTK_POS_BOTTOM, s);
    g_sprintf ((s = buf), fmtb, (int) (v =
            ptz->controller->pan_speed_max + 0.5));
    gtk_scale_add_mark (GTK_SCALE (scale_pan_speed), v, GTK_POS_BOTTOM, s);
    g_sprintf ((s = buf), fmtb, (int) (v =
            (ptz->controller->pan_speed_max -
                ptz->controller->pan_speed_min) / 2 + 0.5));
    gtk_scale_add_mark (GTK_SCALE (scale_pan_speed), v, GTK_POS_BOTTOM, s);

    g_sprintf ((s = buf), fmtb, (int) (v =
            ptz->controller->tilt_speed_min + 0.5));
    gtk_scale_add_mark (GTK_SCALE (scale_tilt_speed), v, GTK_POS_BOTTOM, s);
    g_sprintf ((s = buf), fmtb, (int) (v =
            ptz->controller->tilt_speed_max + 0.5));
    gtk_scale_add_mark (GTK_SCALE (scale_tilt_speed), v, GTK_POS_BOTTOM, s);
    g_sprintf ((s = buf), fmtb, (int) (v =
            (ptz->controller->tilt_speed_max -
                ptz->controller->tilt_speed_min) / 2 + 0.5));
    gtk_scale_add_mark (GTK_SCALE (scale_tilt_speed), v, GTK_POS_BOTTOM, s);

    fmtb = "<small><sub><b>%.1f</b></sub></small>";
    g_sprintf ((s = buf), fmtb, (v = 0.0));
    gtk_scale_add_mark (GTK_SCALE (scale_zoom_speed), v, GTK_POS_BOTTOM, s);
    g_sprintf ((s = buf), fmtb, (v = 1.0));
    gtk_scale_add_mark (GTK_SCALE (scale_zoom_speed), v, GTK_POS_BOTTOM, s);
    g_sprintf ((s = buf), fmtb, (v = 0.5));
    gtk_scale_add_mark (GTK_SCALE (scale_zoom_speed), v, GTK_POS_BOTTOM, s);

    g_sprintf ((s = buf), fmtb, (v = 0.0));
    gtk_scale_add_mark (GTK_SCALE (scale_zoom), v, GTK_POS_BOTTOM, s);
    g_sprintf ((s = buf), fmtb, (v = 1.0));
    gtk_scale_add_mark (GTK_SCALE (scale_zoom), v, GTK_POS_BOTTOM, s);
    g_sprintf ((s = buf), fmtb, (v = 0.5));
    gtk_scale_add_mark (GTK_SCALE (scale_zoom), v, GTK_POS_BOTTOM, s);
  }

  if (strcmp (ptz_control_protocol, "visca-sony") == 0) {
    gtk_widget_set_sensitive (box_control_pan, FALSE);
    gtk_widget_set_sensitive (box_control_tilt, FALSE);
    gtk_widget_set_sensitive (box_control_zoom, FALSE);
  }

  /*
     g_signal_connect (G_OBJECT (scale_pan_speed), "value-changed",
     G_CALLBACK (gst_switch_ptz_window_closed), ptz);
   */
  g_signal_connect (ptz->adjust_pan_speed, "value-changed",
      G_CALLBACK (gst_switch_ptz_pan_speed_changed), ptz);
  g_signal_connect (ptz->adjust_tilt_speed, "value-changed",
      G_CALLBACK (gst_switch_ptz_tilt_speed_changed), ptz);
  g_signal_connect (ptz->adjust_zoom_speed, "value-changed",
      G_CALLBACK (gst_switch_ptz_zoom_speed_changed), ptz);
  g_signal_connect (ptz->adjust_zoom, "value-changed",
      G_CALLBACK (gst_switch_ptz_zoom_changed), ptz);

  g_signal_connect (control_buttons[0][0], "pressed",
      G_CALLBACK (gst_switch_ptz_button_pressed_left_top), ptz);
  g_signal_connect (control_buttons[0][1], "pressed",
      G_CALLBACK (gst_switch_ptz_button_pressed_top), ptz);
  g_signal_connect (control_buttons[0][2], "pressed",
      G_CALLBACK (gst_switch_ptz_button_pressed_top_right), ptz);
  g_signal_connect (control_buttons[1][0], "pressed",
      G_CALLBACK (gst_switch_ptz_button_pressed_left), ptz);
  g_signal_connect (control_buttons[1][1], "pressed",
      G_CALLBACK (gst_switch_ptz_button_pressed_center), ptz);
  g_signal_connect (control_buttons[1][2], "pressed",
      G_CALLBACK (gst_switch_ptz_button_pressed_right), ptz);
  g_signal_connect (control_buttons[2][0], "pressed",
      G_CALLBACK (gst_switch_ptz_button_pressed_bottom_left), ptz);
  g_signal_connect (control_buttons[2][1], "pressed",
      G_CALLBACK (gst_switch_ptz_button_pressed_bottom), ptz);
  g_signal_connect (control_buttons[2][2], "pressed",
      G_CALLBACK (gst_switch_ptz_button_pressed_right_bottom), ptz);

  g_signal_connect (control_buttons[0][0], "released",
      G_CALLBACK (gst_switch_ptz_button_released_left_top), ptz);
  g_signal_connect (control_buttons[0][1], "released",
      G_CALLBACK (gst_switch_ptz_button_released_top), ptz);
  g_signal_connect (control_buttons[0][2], "released",
      G_CALLBACK (gst_switch_ptz_button_released_top_right), ptz);
  g_signal_connect (control_buttons[1][0], "released",
      G_CALLBACK (gst_switch_ptz_button_released_left), ptz);
  g_signal_connect (control_buttons[1][2], "released",
      G_CALLBACK (gst_switch_ptz_button_released_right), ptz);
  g_signal_connect (control_buttons[2][0], "released",
      G_CALLBACK (gst_switch_ptz_button_released_bottom_left), ptz);
  g_signal_connect (control_buttons[2][1], "released",
      G_CALLBACK (gst_switch_ptz_button_released_bottom), ptz);
  g_signal_connect (control_buttons[2][2], "released",
      G_CALLBACK (gst_switch_ptz_button_released_right_bottom), ptz);

  do_update = TRUE;
  gst_switch_ptz_update_xy (ptz);
  do_update = FALSE;

  g_timeout_add (300, (GSourceFunc) gst_switch_ptz_update, ptz);
  g_timeout_add (100, (GSourceFunc) gst_switch_ptz_update_xy, ptz);
  //g_timeout_add (50, (GSourceFunc) gst_switch_ptz_update_d, ptz);
}
gint main (gint argc, gchar *argv[])
{
    gtk_init (&argc, &argv);
    gst_init (&argc, &argv);

    GstElement* pipeline = gst_pipeline_new ("pipeline");

    //window to control the states
    GtkWidget* window_control = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    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_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_grid_new ();
    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_grid_attach (GTK_GRID (table), button_state_null, 0, 0, 1, 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_grid_attach (GTK_GRID (table), button_state_ready, 0, 1, 1, 1);
    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_grid_attach (GTK_GRID (table), button_state_paused, 0, 2, 1, 1);
    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_grid_attach (GTK_GRID (table), button_state_playing, 0, 3, 1, 1);
    gtk_widget_show (button_state_playing);

    //change framerate
    GtkWidget* slider_fps = gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL,
        1, 30, 2);
    g_signal_connect (G_OBJECT (slider_fps), "format-value",
        G_CALLBACK (slider_fps_cb), pipeline);
    gtk_grid_attach (GTK_GRID (table), slider_fps, 1, 0, 1, 3);
    gtk_widget_show (slider_fps);

    gtk_widget_show (table);
    gtk_widget_show (window_control);

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

    GstCaps *caps = gst_caps_new_simple("video/x-raw",
                                        "width", G_TYPE_INT, 640,
                                        "height", G_TYPE_INT, 480,
                                        "framerate", GST_TYPE_FRACTION, 25, 1,
                                        "format", G_TYPE_STRING, "RGBA",
                                        NULL) ;

    gst_bin_add_many (GST_BIN (pipeline), videosrc, upload, glfiltercube, videosink, NULL);

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

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

    //set window id on this event
    GstBus* bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
    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);

    //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_main();

    return 0;
}
Пример #19
0
gint main (gint argc, gchar *argv[])
{
    GtkWidget *area;
    gst_init (&argc, &argv);
    gtk_init (&argc, &argv);

    GstElement* pipeline = gst_pipeline_new ("pipeline");
    GstElement* videosrc  = gst_element_factory_make ("videotestsrc", "videotestsrc");
    GstElement* videosink = gst_element_factory_make ("glimagesink", "glimagesink");

    gst_bin_add_many (GST_BIN (pipeline), videosrc, videosink, NULL);

    gboolean link_ok = gst_element_link_many(videosrc, videosink, NULL) ;
    if(!link_ok)
    {
        g_warning("Failed to link an element!\n") ;
        return -1;
    }

    //set window id on this event
    GstBus* bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
    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_element_set_state(pipeline, GST_STATE_READY);

    area = gtk_drawing_area_new();
    gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, area, NULL);
    gst_object_unref (bus);

    //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 gstvideooverlay 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_grid_new ();
    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_grid_attach (GTK_GRID (table), button_state_null, 0, 0, 1, 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_grid_attach (GTK_GRID (table), button_state_ready, 0, 1, 1, 1);
    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_grid_attach (GTK_GRID (table), button_state_paused, 0, 2, 1, 1);
    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_grid_attach (GTK_GRID (table), button_state_playing, 0, 3, 1, 1);
    gtk_widget_show (button_state_playing);

    //change framerate
    GtkWidget* slider_fps = gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL,
        1, 30, 2);
    g_signal_connect (G_OBJECT (slider_fps), "format-value",
        G_CALLBACK (slider_fps_cb), pipeline);
    gtk_grid_attach (GTK_GRID (table), slider_fps, 1, 0, 1, 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);

    //area where the video is drawn
    gtk_container_add (GTK_CONTAINER (window), area);

    gtk_widget_realize(area);

    //needed when being in GST_STATE_READY, GST_STATE_PAUSED
    //or resizing/obscuring the window
    g_signal_connect(area, "draw", G_CALLBACK(draw_cb), videosink);

    gtk_widget_show_all (window);

    gst_element_set_state(pipeline, GST_STATE_PLAYING);

    gtk_main();

    return 0;
}
Пример #20
0
int music_build_element_widgets () {
	int i = 0;
	for (i = 0; i < 9; i++) {
		label_music_info[i] = gtk_label_new(NULL);
		gtk_label_set_width_chars(GTK_LABEL(label_music_info[i]), 15);
		gtk_label_set_max_width_chars(GTK_LABEL(label_music_info[i]), 150);
		gtk_label_set_line_wrap(GTK_LABEL(label_music_info[i]), TRUE);
	}
	separator_music_info = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
	
	for (i = 0; i < 9; i++) {
		label_music_lyric[i] = gtk_label_new(NULL);
		gtk_label_set_max_width_chars(GTK_LABEL(label_music_lyric[i]), 305);
// 		gtk_label_set_line_wrap(GTK_LABEL(label_music_lyric[i]), TRUE);
	}
	gtk_label_set_selectable(GTK_LABEL(label_music_lyric[4]), TRUE);
	gtk_label_set_use_underline (GTK_LABEL(label_music_lyric[4]), TRUE);
	gtk_label_set_use_markup (GTK_LABEL(label_music_lyric[4]), TRUE);
	gtk_label_set_pattern (GTK_LABEL(label_music_lyric[4]), "________");
	separator_music_lyric1 =  gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	separator_music_lyric2 =  gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);

	button_music_start_server = gtk_button_new_with_label("启动服务器");
// 	set_button_music_start_server(button_music_start_server);
	
	button_music_exit_server = gtk_button_new_with_label("关闭服务器");
// 	set_button_music_exit_server(button_music_exit_server);
	
	
	button_music_play = gtk_button_new();
// 	box_music_play = button_with_image("/usr/share/raspi_remote_control/ui_images/ui_images_music/play.png");
// 	box_music_pause = button_with_image("/usr/share/raspi_remote_control/ui_images/ui_images_music/pause.png");
	image_music_play = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/play.png");
	image_music_play_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/play_light.png");
	image_music_pause = gtk_image_new_from_file ("/usr/share/raspi_remote_control/ui_images/ui_images_music/pause.png");
	image_music_pause_light = gtk_image_new_from_file ("/usr/share/raspi_remote_control/ui_images/ui_images_music/pause_light.png");
	gtk_button_set_relief(GTK_BUTTON(button_music_play), GTK_RELIEF_NONE);
	set_button_music_play(button_music_play);
	
	button_music_pause = gtk_button_new_with_label("暂停");
// 	set_button_music_pause(button_music_pause);
	
	button_music_unpause = gtk_button_new_with_label("取消暂停");
// 	set_button_music_unpause(button_music_unpause);
	
// 	button_music_stop = gtk_button_new_with_label("停止");
	button_music_stop = gtk_button_new();
	image_music_stop = gtk_image_new_from_file ("/usr/share/raspi_remote_control/ui_images/ui_images_music/stop.png");
	image_music_stop_light = gtk_image_new_from_file ("/usr/share/raspi_remote_control/ui_images/ui_images_music/stop_light.png");
	gtk_button_set_image(GTK_BUTTON(button_music_stop), image_music_stop);
	gtk_button_set_relief(GTK_BUTTON(button_music_stop), GTK_RELIEF_NONE);
	set_button_music_stop(button_music_stop);
	
// 	button_music_next = gtk_button_new_with_label("下一首");
	button_music_next = gtk_button_new();
	image_music_next = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/next.png");
	image_music_next_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/next_light.png");
	gtk_button_set_image(GTK_BUTTON(button_music_next), image_music_next);
	gtk_button_set_relief(GTK_BUTTON(button_music_next), GTK_RELIEF_NONE);
	set_button_music_next(button_music_next);
	
// 	button_music_pre = gtk_button_new_with_label("上一首");
	button_music_pre = gtk_button_new();
	image_music_pre = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/pre.png");
	image_music_pre_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/pre_light.png");
	gtk_button_set_image (GTK_BUTTON(button_music_pre), image_music_pre);
	gtk_button_set_relief(GTK_BUTTON(button_music_pre), GTK_RELIEF_NONE);
	set_button_music_pre(button_music_pre);
	

	
	
// 	button_music_volume_up = gtk_button_new_with_label("音量+");
// 	set_button_music_volume_up(button_music_volume_up);
	
// 	button_music_volume_silence = gtk_button_new_with_label("静音");
	button_music_silence = gtk_button_new();
	image_music_silence = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/silence.png");
	image_music_silence_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/silence_light.png");
	image_music_unsilence = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/unsilence.png");
	image_music_unsilence_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/unsilence_light.png");
	gtk_button_set_image (GTK_BUTTON(button_music_silence), image_music_silence);
	gtk_button_set_relief(GTK_BUTTON(button_music_silence), GTK_RELIEF_NONE);
	set_button_music_silence(button_music_silence);
	
	button_music_volume = gtk_volume_button_new();
	set_button_music_volume( button_music_volume);
	
	button_music_reset_list = gtk_button_new_with_label("重设列表");
	set_button_music_reset_list(button_music_reset_list);
	
// 	button_music_choose_path = gtk_button_new_with_label("添加路径");
// 	set_button_music_choose_path(button_music_choose_path);
// 	music_path_dialog = gtk_file_chooser_widget_new(GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
	music_path_dialog = gtk_file_chooser_dialog_new ("test_title", NULL, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, "test_button_text", NULL);
	button_music_choose_path = gtk_file_chooser_button_new_with_dialog (music_path_dialog);
	gtk_file_chooser_button_set_title (GTK_FILE_CHOOSER_BUTTON(button_music_choose_path), "添加路径");
// 	gtk_file_chooser_set_select_multiple (music_path_dialog, TRUE);
	
	
	button_music_delete_path = gtk_button_new_with_label("删除当前路径");
	set_button_music_delete_path(button_music_delete_path);
	
	scale_music_process = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 100, 1);
	set_scale_music_process(scale_music_process);
	
	label_music_cur_time = gtk_label_new ("--:--:--");
	label_music_total_time = gtk_label_new ("--:--:--");
	
	switch_music_autonext = gtk_switch_new ();
	set_switch_music_autonext ();
	label_music_autonext = gtk_label_new ("AutoNext: ");
	
	switch_music_repeat = gtk_switch_new ();
	set_switch_music_repeat ();
	label_music_repeat = gtk_label_new ("Repeat: ");
	
	switch_music_shuffle = gtk_switch_new ();
	set_switch_music_shuffle ();
	label_music_shuffle = gtk_label_new ("Shuffle: ");
	
	radio_button_music_mode_shuffle = gtk_radio_button_new (NULL);
	label_music_mode_shuffle = gtk_label_new ("随机:");
	radio_button_music_mode_loop_list = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio_button_music_mode_shuffle));
	label_music_mode_loop_list = gtk_label_new ("列表循环:");
	radio_button_music_mode_play_list = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio_button_music_mode_shuffle));
	label_music_mode_play_list = gtk_label_new ("播放列表:");
	radio_button_music_mode_loop_one = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio_button_music_mode_shuffle));
	label_music_mode_loop_one = gtk_label_new ("单曲:");
	spinner_music_mode_changing = gtk_spinner_new ();
	
	set_radio_button_music_mode ();
	
	
	store_music_dir_list = gtk_tree_store_new(dir_n_columns, G_TYPE_STRING);
	tree_view_music_dir_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store_music_dir_list));
	text_renderer_music_dir_list = gtk_cell_renderer_text_new ();
	column_music_dir_list = gtk_tree_view_column_new_with_attributes (NULL, text_renderer_music_dir_list, "text", dir_name, NULL);
	gtk_tree_view_column_set_fixed_width(column_music_dir_list, 100);
	gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view_music_dir_list), column_music_dir_list);
	music_dir_list_sw_adj_h = gtk_adjustment_new(100, 0, 100, 1, 1, 50);
	music_dir_list_sw = gtk_scrolled_window_new(NULL, music_dir_list_sw_adj_h);
	gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(music_dir_list_sw), 330);
	gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(music_dir_list_sw), 100);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(music_dir_list_sw), GTK_SHADOW_NONE);
// 	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(music_dir_list_sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(music_dir_list_sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_container_add(GTK_CONTAINER(music_dir_list_sw), tree_view_music_dir_list);
	
	selection_music_dir_list = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view_music_dir_list));
	set_tree_view_music_dir_list ();
	

	store_music_list = gtk_tree_store_new(list_n_columns, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
// 	char file_index[BUFSIZ];
// 	printf("music_list_num is: %s\n", music_list_num);
// 	while (i < music_list_num) {
// // 		printf("%d: %s\n", i, music_list[i]);
// 		sprintf(file_index, "%d", i + 1);
// 		gtk_tree_store_append(store_music_list, &iter_music_list, NULL);
// 		gtk_tree_store_set (store_music_list, &iter_music_list, list_index, file_index, list_title, music_list[i], list_total_sec, "03:00", -1);
// 		i++;
// 	}
// 	
	tree_view_music_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store_music_list));
	
	text_renderer_music_list = gtk_cell_renderer_text_new ();
	column_music_list = gtk_tree_view_column_new_with_attributes (NULL, text_renderer_music_list, "text", list_index, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view_music_list), column_music_list);
	
	gtk_tree_view_column_set_title(column_music_list, "序号");
	
	text_renderer_music_list = gtk_cell_renderer_text_new ();
	column_music_list = gtk_tree_view_column_new_with_attributes (NULL, text_renderer_music_list, "text", list_title, NULL);
	gtk_tree_view_column_set_fixed_width(column_music_list, 100);
	gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view_music_list), column_music_list);
	
// 	text_renderer_music_list = gtk_cell_renderer_text_new ();
// 	column_music_list = gtk_tree_view_column_new_with_attributes (NULL, text_renderer_music_list, "text", list_total_sec, NULL);
// 	gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view_music_list), column_music_list);
	
	
	
	music_list_sw_adj_h = gtk_adjustment_new(100, 0, 100, 1, 1, 50);
	music_list_sw = gtk_scrolled_window_new(NULL, music_list_sw_adj_h);
	gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(music_list_sw), 370);
	gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(music_list_sw), 200);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(music_list_sw), GTK_SHADOW_NONE);
// 	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(music_list_sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(music_list_sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_container_add(GTK_CONTAINER(music_list_sw), tree_view_music_list);
	
	selection_music_list = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view_music_list));
	set_tree_view_music_list ();
	return 1;
}
Пример #21
0
static void compressor_configure (void)
{
    if (config_window == NULL)
    {
        GtkWidget * vbox, * hbox, * slider, * button;

        config_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        gtk_window_set_type_hint ((GtkWindow *) config_window,
         GDK_WINDOW_TYPE_HINT_DIALOG);
        gtk_window_set_resizable ((GtkWindow *) config_window, FALSE);
        gtk_window_set_title ((GtkWindow *) config_window, _("Dynamic Range "
         "Compressor Preferences"));
        gtk_container_set_border_width ((GtkContainer *) config_window, 6);
        g_signal_connect (config_window, "destroy", (GCallback)
         gtk_widget_destroyed, & config_window);

        vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
        gtk_container_add ((GtkContainer *) config_window, vbox);

        hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
        gtk_box_pack_start ((GtkBox *) vbox, hbox, FALSE, FALSE, 0);

        gtk_box_pack_start ((GtkBox *) hbox, gtk_label_new (_("Center "
         "volume:")), FALSE, FALSE, 0);

        slider = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0.1, 1.0, 0.1);
        gtk_range_set_value ((GtkRange *) slider, compressor_center);
        gtk_widget_set_size_request (slider, 100, -1);
        gtk_box_pack_start ((GtkBox *) hbox, slider, FALSE, FALSE, 0);
        g_signal_connect (slider, "value-changed", (GCallback) value_changed,
         & compressor_center);

        hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
        gtk_box_pack_start ((GtkBox *) vbox, hbox, FALSE, FALSE, 0);

        gtk_box_pack_start ((GtkBox *) hbox, gtk_label_new (_("Dynamic "
         "range:")), FALSE, FALSE, 0);

        slider = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0.0, 3.0, 0.1);
        gtk_range_set_value ((GtkRange *) slider, compressor_range);
        gtk_widget_set_size_request (slider, 250, -1);
        gtk_box_pack_start ((GtkBox *) hbox, slider, FALSE, FALSE, 0);
        g_signal_connect (slider, "value-changed", (GCallback) value_changed,
         & compressor_range);

        hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
        gtk_box_pack_start ((GtkBox *) vbox, hbox, FALSE, FALSE, 0);

        button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
        gtk_box_pack_end ((GtkBox *) hbox, button, FALSE, FALSE, 0);
        gtk_widget_set_can_default (button, TRUE);
        gtk_widget_grab_default (button);
        g_signal_connect_swapped (button, "clicked", (GCallback)
         gtk_widget_destroy, config_window);

        audgui_destroy_on_escape (config_window);

        gtk_widget_show_all (vbox);
    }

    gtk_window_present ((GtkWindow *) config_window);
}
Пример #22
0
int
main (int   argc,
      char *argv[])
{
  GtkWidget *window, *widget, *vbox, *button;
  GtkWidget *offscreen = NULL;
  gboolean use_offscreen;

  gtk_init (&argc, &argv);

  use_offscreen = argc == 1;

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 300,300);

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

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  gtk_container_add (GTK_CONTAINER (window), vbox);

  scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
                                    0, G_PI * 2, 0.01);
  gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);

  button = gtk_button_new_with_label ("Remove child 2");
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

  if (use_offscreen)
    {
      offscreen = gtk_offscreen_box_new ();

      g_signal_connect (scale, "value_changed",
                        G_CALLBACK (scale_changed),
                        offscreen);
    }
  else
    {
      offscreen = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
    }

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

  widget = create_widgets ();
  if (use_offscreen)
    gtk_offscreen_box_add1 (GTK_OFFSCREEN_BOX (offscreen),
			    widget);
  else
    gtk_paned_add1 (GTK_PANED (offscreen), widget);

  widget = create_widgets ();
  if (1)
    {
      GtkWidget *widget2, *box2, *offscreen2;

      offscreen2 = gtk_offscreen_box_new ();
      gtk_box_pack_start (GTK_BOX (widget), offscreen2, FALSE, FALSE, 0);

      g_signal_connect (scale, "value_changed",
                        G_CALLBACK (scale_changed),
                        offscreen2);

      box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
      gtk_offscreen_box_add2 (GTK_OFFSCREEN_BOX (offscreen2), box2);

      widget2 = gtk_button_new_with_label ("Offscreen in offscreen");
      gtk_box_pack_start (GTK_BOX (box2), widget2, FALSE, FALSE, 0);

      widget2 = gtk_entry_new ();
      gtk_entry_set_text (GTK_ENTRY (widget2), "Offscreen in offscreen");
      gtk_box_pack_start (GTK_BOX (box2), widget2, FALSE, FALSE, 0);
    }

  if (use_offscreen)
    gtk_offscreen_box_add2 (GTK_OFFSCREEN_BOX (offscreen), widget);
  else
    gtk_paned_add2 (GTK_PANED (offscreen), widget);

  gtk_widget_show_all (window);

  g_signal_connect (G_OBJECT (button), "clicked",
                    G_CALLBACK (remove_clicked),
                    widget);

  gtk_main ();

  return 0;
}
Пример #23
0
/**
 * \fn void dialog_simulator_create()
 * \brief Function to create the main window.
 */
void
dialog_simulator_create ()
{
  static char *str_exit, *str_options, *str_start, *str_stop, *str_save,
    *str_help;
  static char *tip_exit, *tip_options, *tip_start, *tip_stop, *tip_save,
    *tip_help;
  DialogSimulator *dlg;

#if DEBUG
  printf ("dialog_simulator_create: start\n");
#endif

  dlg = dialog_simulator;
#if HAVE_SDL
  exit_event->type = SDL_QUIT;
#endif

  str_options = gettext ("_Options");
  str_start = gettext ("S_tart");
  str_stop = gettext ("Sto_p");
  str_save = gettext ("_Save");
  str_help = gettext ("_Help");
  str_exit = gettext ("E_xit");
  tip_options = gettext ("Fractal options");
  tip_start = gettext ("Start fractal growing");
  tip_stop = gettext ("Stop fractal growing");
  tip_save = gettext ("Save graphical");
  tip_help = gettext ("Help");
  tip_exit = gettext ("Exit");

  dlg->toolbar = (GtkToolbar *) gtk_toolbar_new ();

  dlg->button_options = (GtkToolButton *) gtk_tool_button_new
    (gtk_image_new_from_icon_name
     ("preferences-system", GTK_ICON_SIZE_SMALL_TOOLBAR), str_options);
  gtk_widget_set_tooltip_text (GTK_WIDGET (dlg->button_options), tip_options);
  gtk_toolbar_insert (dlg->toolbar, GTK_TOOL_ITEM (dlg->button_options), -1);
  g_signal_connect
    (dlg->button_options, "clicked", dialog_options_create, NULL);

  dlg->button_start = (GtkToolButton *) gtk_tool_button_new
    (gtk_image_new_from_icon_name
     ("system-run", GTK_ICON_SIZE_SMALL_TOOLBAR), str_start);
  gtk_widget_set_tooltip_text (GTK_WIDGET (dlg->button_start), tip_start);
  gtk_toolbar_insert (dlg->toolbar, GTK_TOOL_ITEM (dlg->button_start), -1);
  g_signal_connect (dlg->button_start, "clicked", fractal, NULL);

  dlg->button_stop = (GtkToolButton *) gtk_tool_button_new
    (gtk_image_new_from_icon_name
     ("process-stop", GTK_ICON_SIZE_SMALL_TOOLBAR), str_stop);
  gtk_widget_set_tooltip_text (GTK_WIDGET (dlg->button_stop), tip_stop);
  gtk_toolbar_insert (dlg->toolbar, GTK_TOOL_ITEM (dlg->button_stop), -1);
  g_signal_connect (dlg->button_stop, "clicked", fractal_stop, NULL);

  dlg->button_save = (GtkToolButton *) gtk_tool_button_new
    (gtk_image_new_from_icon_name
     ("document-save", GTK_ICON_SIZE_SMALL_TOOLBAR), str_save);
  gtk_widget_set_tooltip_text (GTK_WIDGET (dlg->button_save), tip_save);
  gtk_toolbar_insert (dlg->toolbar, GTK_TOOL_ITEM (dlg->button_save), -1);
  g_signal_connect (dlg->button_save, "clicked", dialog_simulator_save, NULL);

  dlg->button_help = (GtkToolButton *) gtk_tool_button_new
    (gtk_image_new_from_icon_name
     ("help-about", GTK_ICON_SIZE_SMALL_TOOLBAR), str_help);
  gtk_widget_set_tooltip_text (GTK_WIDGET (dlg->button_help), tip_help);
  gtk_toolbar_insert (dlg->toolbar, GTK_TOOL_ITEM (dlg->button_help), -1);
  g_signal_connect (dlg->button_help, "clicked", dialog_simulator_help, NULL);

  dlg->button_exit = (GtkToolButton *) gtk_tool_button_new
    (gtk_image_new_from_icon_name
     ("application-exit", GTK_ICON_SIZE_SMALL_TOOLBAR), str_exit);
  gtk_widget_set_tooltip_text (GTK_WIDGET (dlg->button_exit), tip_exit);
  gtk_toolbar_insert (dlg->toolbar, GTK_TOOL_ITEM (dlg->button_exit), -1);
#if HAVE_FREEGLUT
  g_signal_connect (dlg->button_exit, "clicked", glutLeaveMainLoop, NULL);
#elif HAVE_SDL
  g_signal_connect_swapped (dlg->button_exit, "clicked",
                            (void (*)) SDL_PushEvent, exit_event);
#elif HAVE_GLFW
  g_signal_connect (dlg->button_exit, "clicked", (void (*)) window_close, NULL);
#endif

  dlg->label_time = (GtkLabel *) gtk_label_new (gettext ("Calculating time"));
  dlg->entry_time =
    (GtkSpinButton *) gtk_spin_button_new_with_range (0., 1.e6, 0.1);
  gtk_widget_set_sensitive (GTK_WIDGET (dlg->entry_time), 0);

  dlg->progress = (GtkProgressBar *) gtk_progress_bar_new ();
  gtk_progress_bar_set_text (dlg->progress, gettext ("Progress"));

  dlg->hscale = (GtkScale *) gtk_scale_new_with_range
    (GTK_ORIENTATION_HORIZONTAL, -90., 0., 1.);
  dlg->vscale = (GtkScale *) gtk_scale_new_with_range
    (GTK_ORIENTATION_HORIZONTAL, 0., 90., 1.);
  gtk_scale_set_digits (dlg->hscale, 0);
  gtk_scale_set_digits (dlg->vscale, 0);
  gtk_range_set_value (GTK_RANGE (dlg->hscale), phid);
  gtk_range_set_value (GTK_RANGE (dlg->vscale), thetad);
  g_signal_connect (dlg->hscale, "value-changed", set_perspective, NULL);
  g_signal_connect (dlg->vscale, "value-changed", set_perspective, NULL);

  dlg->label_horizontal = (GtkLabel *) gtk_label_new
    (gettext ("Horizontal perspective angle (º)"));
  dlg->label_vertical = (GtkLabel *) gtk_label_new
    (gettext ("Vertical perspective angle (º)"));

  dlg->grid = (GtkGrid *) gtk_grid_new ();
  gtk_grid_attach (dlg->grid, GTK_WIDGET (dlg->toolbar), 0, 0, 3, 1);
  gtk_grid_attach (dlg->grid, GTK_WIDGET (dlg->progress), 0, 1, 1, 1);
  gtk_grid_attach (dlg->grid, GTK_WIDGET (dlg->label_time), 1, 1, 1, 1);
  gtk_grid_attach (dlg->grid, GTK_WIDGET (dlg->entry_time), 2, 1, 1, 1);
  gtk_grid_attach (dlg->grid, GTK_WIDGET (dlg->label_horizontal), 0, 2, 1, 1);
  gtk_grid_attach (dlg->grid, GTK_WIDGET (dlg->hscale), 1, 2, 2, 1);
  gtk_grid_attach (dlg->grid, GTK_WIDGET (dlg->label_vertical), 0, 3, 1, 1);
  gtk_grid_attach (dlg->grid, GTK_WIDGET (dlg->vscale), 1, 3, 2, 1);

  dlg->logo = gtk_image_get_pixbuf
    (GTK_IMAGE (gtk_image_new_from_file ("logo.png")));
  dlg->logo_min = gtk_image_get_pixbuf
    (GTK_IMAGE (gtk_image_new_from_file ("logo2.png")));

  dlg->window = (GtkWindow *) gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (dlg->window, gettext ("Fractal growing"));
  gtk_window_set_icon (dlg->window, dlg->logo_min);
  gtk_container_add (GTK_CONTAINER (dlg->window), GTK_WIDGET (dlg->grid));
  gtk_widget_show_all (GTK_WIDGET (dlg->window));
#if HAVE_FREEGLUT
  g_signal_connect (dlg->window, "delete_event", glutLeaveMainLoop, NULL);
#elif HAVE_SDL
  g_signal_connect_swapped (dlg->window, "delete_event",
                            (void (*)) SDL_PushEvent, exit_event);
#elif HAVE_GLFW
  g_signal_connect (dlg->window, "delete_event", (void (*)) window_close, NULL);
#endif

  set_perspective ();
  dialog_simulator_update ();
#if DEBUG
  printf ("dialog_simulator_create: end\n");
#endif
}
Пример #24
0
static void
nemo_status_bar_constructed (GObject *object)
{
    NemoStatusBar *bar = NEMO_STATUS_BAR (object);
    G_OBJECT_CLASS (nemo_status_bar_parent_class)->constructed (object);

    GtkToolbar *toolbar;
    GtkWidget *widget_box;
    GtkToolItem *item;
    GtkWidget *statusbar = gtk_statusbar_new ();
    GtkActionGroup *action_group;
    GtkStyleContext *context;

    bar->real_statusbar = statusbar;

    GtkIconSize size = gtk_icon_size_from_name (NEMO_STATUSBAR_ICON_SIZE_NAME);

    context = gtk_widget_get_style_context (GTK_WIDGET (bar));
    gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOOLBAR);
    gtk_container_set_border_width (GTK_CONTAINER (bar), 1);

    GtkWidget *button, *icon;

    button = gtk_toggle_button_new ();
    icon = gtk_image_new_from_icon_name ("sidebar-places-symbolic", size);
    gtk_button_set_image (GTK_BUTTON (button), icon);
    gtk_widget_set_tooltip_text (GTK_WIDGET (button), _("Show Places"));
    bar->places_button = button;
    gtk_box_pack_start (GTK_BOX (bar), button, FALSE, FALSE, 2);
    g_signal_connect (GTK_BUTTON (button), "clicked",
                      G_CALLBACK (action_places_toggle_callback), bar);

    button = gtk_toggle_button_new ();
    icon = gtk_image_new_from_icon_name ("sidebar-tree-symbolic", size);
    gtk_button_set_image (GTK_BUTTON (button), icon);
    gtk_widget_set_tooltip_text (GTK_WIDGET (button), _("Show Treeview"));
    bar->tree_button = button;
    gtk_box_pack_start (GTK_BOX (bar), button, FALSE, FALSE, 2);
    g_signal_connect (GTK_BUTTON (button), "clicked",
                      G_CALLBACK (action_treeview_toggle_callback), bar);

    GtkWidget *sep = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
    gtk_box_pack_start (GTK_BOX (bar), sep, FALSE, FALSE, 6);
    gtk_widget_show (sep);
    bar->separator = sep;

    button = gtk_button_new ();
    icon = gtk_image_new_from_icon_name ("sidebar-hide-symbolic", size);
    gtk_button_set_image (GTK_BUTTON (button), icon);
    gtk_widget_set_tooltip_text (GTK_WIDGET (button), _("Hide the Sidebar (F9)"));
    bar->hide_button = button;
    gtk_box_pack_start (GTK_BOX (bar), button, FALSE, FALSE, 2);
    g_signal_connect (GTK_BUTTON (button), "clicked",
                      G_CALLBACK (action_hide_sidebar_callback), bar);

    button = gtk_button_new ();
    icon = gtk_image_new_from_icon_name ("sidebar-show-symbolic", size);
    gtk_button_set_image (GTK_BUTTON (button), icon);
    gtk_widget_set_tooltip_text (GTK_WIDGET (button), _("Show the Sidebar (F9)"));
    bar->show_button = button;
    gtk_box_pack_start (GTK_BOX (bar), button, FALSE, FALSE, 2);
    g_signal_connect (GTK_BUTTON (button), "clicked",
                      G_CALLBACK (action_show_sidebar_callback), bar);

    gtk_box_pack_start (GTK_BOX (bar), statusbar, TRUE, TRUE, 10);

    GtkWidget *zoom_slider = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 6.0, 1.0);
    gtk_widget_set_tooltip_text (GTK_WIDGET (zoom_slider), _("Adjust zoom level"));
    bar->zoom_slider = zoom_slider;

    gtk_box_pack_start (GTK_BOX (bar), zoom_slider, FALSE, FALSE, 2);

    gtk_widget_set_size_request (GTK_WIDGET (zoom_slider), SLIDER_WIDTH, 0);
    gtk_scale_set_draw_value (GTK_SCALE (zoom_slider), FALSE);
    gtk_range_set_increments (GTK_RANGE (zoom_slider), 1.0, 1.0);
    gtk_range_set_round_digits (GTK_RANGE (zoom_slider), 0);

    gtk_widget_show_all (GTK_WIDGET (bar));

    g_signal_connect_object (NEMO_WINDOW (bar->window), "notify::show-sidebar",
                             G_CALLBACK (sidebar_state_changed_cb), bar, G_CONNECT_AFTER);

    g_signal_connect_object (NEMO_WINDOW (bar->window), "notify::sidebar-view-id",
                           G_CALLBACK (sidebar_type_changed_cb), bar, G_CONNECT_AFTER);

    g_signal_connect (GTK_RANGE (zoom_slider), "value-changed",
                      G_CALLBACK (on_slider_changed_cb), bar);

    GtkWidget *cont = gtk_statusbar_get_message_area (GTK_STATUSBAR (statusbar));

    GList *children = gtk_container_get_children (GTK_CONTAINER (cont));

    gtk_box_set_child_packing (GTK_BOX (cont),
                               GTK_WIDGET (children->data),
                               TRUE, FALSE, 10, GTK_PACK_START);

    nemo_status_bar_sync_button_states (bar);
}
int
main (int argc, char **argv)
{
    GdkScreen *screen;
    GtkWidget *nb;
    GtkWidget *general_vbox;
    GtkWidget *behaviour_vbox;
    GtkWidget *placement_vbox;
    GtkWidget *widget;
    GtkWidget *vbox;
    GtkWidget *vbox1;
    GtkWidget *hbox;
    GtkWidget *hbox1;
    GtkWidget *hbox2;
    GtkWidget *hbox3;
    GtkWidget *content_area;
    gchar *str;
    const char *current_wm;
    int i;

    bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
    textdomain (GETTEXT_PACKAGE);

    gtk_init (&argc, &argv);

    screen = gdk_display_get_default_screen (gdk_display_get_default ());
    current_wm = gdk_x11_screen_get_window_manager_name (screen);

    if (g_strcmp0 (current_wm, WM_COMMON_METACITY) == 0) {
        mate_metacity_config_tool ();
        return 0;
    }

    if (g_strcmp0 (current_wm, WM_COMMON_MARCO) != 0) {
        wm_unsupported ();
        return 1;
    }

    marco_settings = g_settings_new (MARCO_SCHEMA);

    /* Window */
    dialog_win = gtk_dialog_new_with_buttons (_("Window Preferences"),
                                              NULL,
                                              GTK_DIALOG_MODAL,
#if GTK_CHECK_VERSION (3, 10, 0)
                                              _("_Help"),
#else
                                              GTK_STOCK_HELP,
#endif
                                              GTK_RESPONSE_HELP,
#if GTK_CHECK_VERSION (3, 10, 0)
                                              _("_Close"),
#else
                                              GTK_STOCK_CLOSE,
#endif
                                              GTK_RESPONSE_CLOSE,
                                              NULL);
    //gtk_window_set_resizable (GTK_WINDOW (dialog_win), FALSE);
    gtk_window_set_icon_name (GTK_WINDOW (dialog_win), "preferences-system-windows");
    gtk_container_set_border_width (GTK_CONTAINER (dialog_win), 10);

    nb = gtk_notebook_new ();

    general_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    behaviour_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    placement_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);

    widget = gtk_label_new (_("General"));
    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_box_pack_start (GTK_BOX (hbox), general_vbox, FALSE, FALSE, 6);
    gtk_notebook_append_page (GTK_NOTEBOOK (nb), hbox, widget);

    widget = gtk_label_new (_("Behaviour"));
    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_box_pack_start (GTK_BOX (hbox), behaviour_vbox, FALSE, FALSE, 6);
    gtk_notebook_append_page (GTK_NOTEBOOK (nb), hbox, widget);

    widget = gtk_label_new (_("Placement"));
    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_box_pack_start (GTK_BOX (hbox), placement_vbox, FALSE, FALSE, 6);
    gtk_notebook_append_page (GTK_NOTEBOOK (nb), hbox, widget);

    /* Compositing manager */
    widget = title_label_new (N_("Compositing Manager"));
    gtk_box_pack_start (GTK_BOX (general_vbox), widget, FALSE, FALSE, 6);

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    hbox1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

    compositing_checkbutton = gtk_check_button_new_with_mnemonic (_("Enable software _compositing window manager"));
    compositing_fast_alt_tab_checkbutton = gtk_check_button_new_with_mnemonic (_("Disable _thumbnails in Alt-Tab"));
    gtk_box_pack_start (GTK_BOX (vbox), compositing_checkbutton, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (hbox1), compositing_fast_alt_tab_checkbutton, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (vbox), hbox1, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (general_vbox), hbox, FALSE, FALSE, 6);

    /* Titlebar buttons */
    widget = title_label_new (N_("Titlebar Buttons"));
    gtk_box_pack_start (GTK_BOX (general_vbox), widget, FALSE, FALSE, 6);

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    widget = gtk_label_new (_("Position:"));
    gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 6);
    titlebar_layout_optionmenu = gtk_combo_box_text_new ();
    gtk_box_pack_start (GTK_BOX (hbox), titlebar_layout_optionmenu, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (general_vbox), hbox, FALSE, FALSE, 6);

    /* New Windows */
    widget = title_label_new (N_("New Windows"));
    gtk_box_pack_start (GTK_BOX (placement_vbox), widget, FALSE, FALSE, 6);

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    center_new_windows_checkbutton = gtk_check_button_new_with_mnemonic (_("Center _new windows"));
    gtk_box_pack_start (GTK_BOX (hbox), center_new_windows_checkbutton, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (placement_vbox), hbox, FALSE, FALSE, 6);

    /* Window Snapping */
    widget = title_label_new (N_("Window Snapping"));
    gtk_box_pack_start (GTK_BOX (placement_vbox), widget, FALSE, FALSE, 6);

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    side_by_side_tiling_checkbutton = gtk_check_button_new_with_mnemonic (_("Enable side by side _tiling"));
    gtk_box_pack_start (GTK_BOX (hbox), side_by_side_tiling_checkbutton, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (placement_vbox), hbox, FALSE, FALSE, 6);

    /* Window Selection */
    widget = title_label_new (N_("Window Selection"));
    gtk_box_pack_start (GTK_BOX (behaviour_vbox), widget, FALSE, FALSE, 6);

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    vbox1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    hbox1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    hbox3 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

    focus_mode_checkbutton = gtk_check_button_new_with_mnemonic (_("_Select windows when the mouse moves over them"));
    gtk_box_pack_start (GTK_BOX (vbox), focus_mode_checkbutton, FALSE, FALSE, 6);

    focus_mode_mouse_checkbutton = gtk_check_button_new_with_mnemonic (_("U_nselect windows when the mouse leaves them"));
    gtk_box_pack_start (GTK_BOX (hbox1), focus_mode_mouse_checkbutton, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 6);

    autoraise_checkbutton = gtk_check_button_new_with_mnemonic (_("_Raise selected windows after an interval"));
    gtk_box_pack_start (GTK_BOX (hbox2), autoraise_checkbutton, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (vbox1), hbox2, FALSE, FALSE, 6);

    autoraise_delay_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    autoraise_delay_slider = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 10, 0.2);

    widget = gtk_label_new_with_mnemonic (_("_Interval before raising:"));
    gtk_box_pack_start (GTK_BOX (autoraise_delay_hbox), widget, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (autoraise_delay_hbox), autoraise_delay_slider, TRUE, TRUE, 6);
    gtk_label_set_mnemonic_widget (GTK_LABEL (widget), autoraise_delay_slider);
    widget = gtk_label_new (_("seconds"));
    gtk_range_set_increments (GTK_RANGE (autoraise_delay_slider), 0.2, 1.0);
    gtk_box_pack_start (GTK_BOX (autoraise_delay_hbox), widget, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (vbox1), autoraise_delay_hbox, FALSE, FALSE, 6);

    gtk_box_pack_start (GTK_BOX (hbox3), vbox1, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (vbox), hbox3, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (behaviour_vbox), hbox, FALSE, FALSE, 6);

    /* Titlebar Action */
    widget = title_label_new (N_("Titlebar Action"));
    gtk_box_pack_start (GTK_BOX (behaviour_vbox), widget, FALSE, FALSE, 6);

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    widget = gtk_label_new_with_mnemonic (_("_Double-click titlebar to perform this action:"));
    gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 6);
    double_click_titlebar_optionmenu = gtk_combo_box_text_new ();
    gtk_label_set_mnemonic_widget (GTK_LABEL (widget), double_click_titlebar_optionmenu);
    gtk_box_pack_start (GTK_BOX (hbox), double_click_titlebar_optionmenu, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (behaviour_vbox), hbox, FALSE, FALSE, 6);

    /* Movement Key */
    widget = title_label_new (N_("Movement Key"));
    gtk_box_pack_start (GTK_BOX (behaviour_vbox), widget, FALSE, FALSE, 6);

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

    widget = gtk_label_new_with_mnemonic (_("To move a window, press-and-hold this key then grab the window:"));
#if GTK_CHECK_VERSION (3, 16, 0)
    gtk_label_set_xalign (GTK_LABEL (widget), 0.0);
    gtk_label_set_yalign (GTK_LABEL (widget), 0.0);
#else
    gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.0);
#endif
    gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 6);

    alt_click_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
    gtk_label_set_mnemonic_widget (GTK_LABEL (widget), alt_click_vbox);
    gtk_box_pack_start (GTK_BOX (vbox), alt_click_vbox, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (behaviour_vbox), hbox, FALSE, FALSE, 6);

    reload_mouse_modifiers ();

    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (titlebar_layout_optionmenu), _("Right"));
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (titlebar_layout_optionmenu), _("Left"));
    str = g_settings_get_string (marco_settings, MARCO_BUTTON_LAYOUT_KEY);
    gtk_combo_box_set_active (GTK_COMBO_BOX (titlebar_layout_optionmenu),
                              g_strcmp0 (str, MARCO_BUTTON_LAYOUT_RIGHT) == 0 ? 0 : 1);
    g_free (str);

    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Roll up"));
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Maximize"));
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Maximize Horizontally"));
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Maximize Vertically"));
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Minimize"));
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("None"));
    gtk_combo_box_set_active (GTK_COMBO_BOX (double_click_titlebar_optionmenu),
                              g_settings_get_enum (marco_settings, MARCO_DOUBLE_CLICK_TITLEBAR_KEY));

    set_alt_click_value ();
    gtk_range_set_value (GTK_RANGE (autoraise_delay_slider),
                         g_settings_get_int (marco_settings, MARCO_AUTORAISE_DELAY_KEY) / 1000.0);
    gtk_combo_box_set_active (GTK_COMBO_BOX (double_click_titlebar_optionmenu),
                              g_settings_get_enum (marco_settings, MARCO_DOUBLE_CLICK_TITLEBAR_KEY));

    g_signal_connect (G_OBJECT (dialog_win), "response",
                      G_CALLBACK (response_cb), NULL);

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

    g_signal_connect (marco_settings, "changed",
                      G_CALLBACK (marco_settings_changed_callback), NULL);

    g_settings_bind (marco_settings,
                     MARCO_COMPOSITING_MANAGER_KEY,
                     compositing_checkbutton,
                     "active",
                     G_SETTINGS_BIND_DEFAULT);

    g_settings_bind (marco_settings,
                     MARCO_COMPOSITING_FAST_ALT_TAB_KEY,
                     compositing_fast_alt_tab_checkbutton,
                     "active",
                     G_SETTINGS_BIND_DEFAULT);

    g_settings_bind (marco_settings,
                     MARCO_SIDE_BY_SIDE_TILING_KEY,
                     side_by_side_tiling_checkbutton,
                     "active",
                     G_SETTINGS_BIND_DEFAULT);

    g_settings_bind (marco_settings,
                     MARCO_CENTER_NEW_WINDOWS_KEY,
                     center_new_windows_checkbutton,
                     "active",
                     G_SETTINGS_BIND_DEFAULT);

    g_signal_connect (marco_settings, "changed::" MARCO_FOCUS_KEY,
                      G_CALLBACK (mouse_focus_changed_callback), NULL);
    /* Initialize the checkbox state appropriately */
    mouse_focus_changed_callback(marco_settings, MARCO_FOCUS_KEY, NULL);

    g_signal_connect (focus_mode_checkbutton, "toggled",
                      G_CALLBACK (mouse_focus_toggled_callback), NULL);
    g_signal_connect (focus_mode_mouse_checkbutton, "toggled",
                      G_CALLBACK (mouse_focus_toggled_callback), NULL);

    g_settings_bind (marco_settings,
                     MARCO_AUTORAISE_KEY,
                     autoraise_checkbutton,
                     "active",
                     G_SETTINGS_BIND_DEFAULT);

    g_signal_connect (autoraise_delay_slider, "value_changed",
                      G_CALLBACK (autoraise_delay_value_changed_callback), NULL);

    g_signal_connect (double_click_titlebar_optionmenu, "changed",
                      G_CALLBACK (double_click_titlebar_changed_callback), NULL);

    g_signal_connect (titlebar_layout_optionmenu, "changed",
                      G_CALLBACK (titlebar_layout_changed_callback), NULL);

    g_signal_connect (G_OBJECT (screen), "window_manager_changed",
                      G_CALLBACK (wm_changed_callback), NULL);

    i = 0;
    while (i < n_mouse_modifiers) {
        g_signal_connect (G_OBJECT (mouse_modifiers[i].radio), "toggled",
                          G_CALLBACK (alt_click_radio_toggled_callback),
                          &mouse_modifiers[i]);
        ++i;
    }

    /* update sensitivity */
    update_sensitivity ();

    capplet_set_icon (dialog_win, "preferences-system-windows");
    content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog_win));
    gtk_box_pack_start (GTK_BOX (content_area), nb, TRUE, TRUE, 0);
    gtk_widget_show_all (dialog_win);

    gtk_main ();

    g_object_unref (marco_settings);

    return 0;
}
Пример #26
0
static void
brasero_song_control_init (BraseroSongControl *object)
{
	BraseroSongControlPrivate *priv;
	GtkWidget *alignment;
	GtkWidget *volume;
	gint volume_value;
	GtkWidget *image;
	GtkWidget *vbox;
	GtkWidget *hbox;
	gpointer value;
	GstBus *bus;

	priv = BRASERO_SONG_CONTROL_PRIVATE (object);

	/* Pipeline */
	priv->pipe = gst_element_factory_make ("playbin2", NULL);
	if (priv->pipe) {
		GstElement *audio_sink;

		audio_sink = gst_element_factory_make ("gconfaudiosink", NULL);
		if (audio_sink)
			g_object_set (G_OBJECT (priv->pipe),
				      "audio-sink", audio_sink,
				      NULL);
	}
	else
		g_warning ("Pipe creation error : can't create pipe.\n");

	bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipe));
	gst_bus_add_watch (bus,
			   (GstBusFunc) brasero_song_control_bus_messages,
			   object);
	gst_object_unref (bus);

	/* Widget itself */
	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_widget_show (vbox);
	gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);
	gtk_container_add (GTK_CONTAINER (object), vbox);

	/* first line title */
	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
	gtk_widget_show (hbox);
	gtk_box_pack_start (GTK_BOX (vbox),
			    hbox,
			    FALSE,
			    FALSE,
			    0);

	priv->header = gtk_label_new (_("No file"));
	gtk_widget_show (priv->header);
	gtk_label_set_use_markup (GTK_LABEL (priv->header), TRUE);
	gtk_label_set_justify (GTK_LABEL (priv->header), GTK_JUSTIFY_LEFT);
	gtk_misc_set_alignment (GTK_MISC (priv->header), 0.0, 0.5);
	gtk_box_pack_start (GTK_BOX (hbox),
			    priv->header,
			    TRUE,
			    TRUE,
			    0);

	priv->size = gtk_label_new (NULL);
	gtk_widget_show (priv->size);
	gtk_label_set_justify (GTK_LABEL (priv->size), GTK_JUSTIFY_LEFT);
	gtk_misc_set_alignment (GTK_MISC (priv->size), 0.0, 0.0);
	gtk_box_pack_end (GTK_BOX (hbox),
	                  priv->size,
	                  FALSE,
	                  FALSE,
	                  0);
	
	/* second line : play, progress, volume button */
	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
	gtk_widget_show (hbox);
	gtk_box_pack_start (GTK_BOX (vbox),
			    hbox,
			    FALSE,
			    FALSE,
			    0);

	alignment = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
	gtk_widget_show (alignment);

	priv->button = gtk_toggle_button_new ();
	gtk_widget_show (priv->button);
	gtk_widget_set_tooltip_text (priv->button, _("Start and stop playing"));
	gtk_container_add (GTK_CONTAINER (alignment), priv->button);
	gtk_box_pack_start (GTK_BOX (hbox),
			    alignment,
			    FALSE,
			    FALSE,
			    0);

	image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_BUTTON);
	gtk_widget_show (image);
	gtk_container_add (GTK_CONTAINER (priv->button), image);
	g_signal_connect (G_OBJECT (priv->button), "clicked",
			  G_CALLBACK (brasero_song_control_button_clicked_cb),
			  object);

	priv->progress = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 1, 500000000);
	gtk_widget_show (priv->progress);
	gtk_scale_set_digits (GTK_SCALE (priv->progress), 0);
	gtk_scale_set_draw_value (GTK_SCALE (priv->progress), FALSE);
	gtk_widget_set_size_request (priv->progress, 80, -1);
	gtk_box_pack_start (GTK_BOX (hbox),
	                    priv->progress,
	                    TRUE,
	                    TRUE,
	                    0);

	g_signal_connect (G_OBJECT (priv->progress),
			  "button-press-event",
			  G_CALLBACK (brasero_song_control_range_button_pressed_cb), object);
	g_signal_connect (G_OBJECT (priv->progress),
			  "button-release-event",
			  G_CALLBACK (brasero_song_control_range_button_released_cb), object);
	g_signal_connect (G_OBJECT (priv->progress),
			  "value-changed",
			  G_CALLBACK (brasero_song_control_range_value_changed),
			  object);

	/* Set saved volume */
	brasero_setting_get_value (brasero_setting_get_default (),
	                           BRASERO_SETTING_PLAYER_VOLUME,
	                           &value);
	volume_value = GPOINTER_TO_INT (value);
	volume_value = CLAMP (volume_value, 0, 100);
	g_object_set (priv->pipe,
		      "volume", (gdouble) volume_value / 100.0,
		      NULL);

	volume = gtk_volume_button_new ();
	gtk_widget_show (volume);
	gtk_box_pack_start (GTK_BOX (hbox),
			    volume,
			    FALSE,
			    FALSE,
			    0);

	gtk_scale_button_set_value (GTK_SCALE_BUTTON (volume), (gdouble) volume_value / 100.0);
	g_signal_connect (volume,
			  "value-changed",
			  G_CALLBACK (brasero_song_control_volume_changed_cb),
			  object);

	gtk_alignment_set_padding (GTK_ALIGNMENT (object), 12, 0, 0, 0);
}
Пример #27
0
static void configure (void)
{
    if (config_window == NULL)
    {
        GtkWidget *vbox, *hbox, *button;

        config_window = gtk_dialog_new_with_buttons
         (_("Bauer Stereophonic-to-Binaural Preferences"), NULL, 0,
         GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
        gtk_window_set_resizable ((GtkWindow *) config_window, FALSE);
        g_signal_connect (config_window, "destroy", (GCallback)
                gtk_widget_destroyed, & config_window);

        vbox = gtk_dialog_get_content_area ((GtkDialog *) config_window);

        hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
        gtk_box_pack_start ((GtkBox *) vbox, hbox, FALSE, FALSE, 0);

        gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(_("Feed level:")), TRUE, FALSE, 0);

        feed_slider = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, BS2B_MINFEED, BS2B_MAXFEED, 1.0);
        gtk_range_set_value (GTK_RANGE(feed_slider), feed_level);
        gtk_widget_set_size_request (feed_slider, 200, -1);
        gtk_box_pack_start ((GtkBox *) hbox, feed_slider, FALSE, FALSE, 0);
        g_signal_connect (feed_slider, "value-changed", (GCallback) feed_value_changed,
                NULL);
        g_signal_connect (feed_slider, "format-value", (GCallback) feed_format_value,
                NULL);

        hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
        gtk_box_pack_start ((GtkBox *) vbox, hbox, FALSE, FALSE, 0);

        gtk_box_pack_start (GTK_BOX(hbox), gtk_label_new(_("Cut frequency:")), TRUE, FALSE, 0);

        fcut_slider = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, BS2B_MINFCUT, BS2B_MAXFCUT, 1.0);
        gtk_range_set_value (GTK_RANGE(fcut_slider), fcut_level);
        gtk_widget_set_size_request (fcut_slider, 200, -1);
        gtk_box_pack_start ((GtkBox *) hbox, fcut_slider, FALSE, FALSE, 0);
        g_signal_connect (fcut_slider, "value-changed", (GCallback) fcut_value_changed,
                NULL);
        g_signal_connect (fcut_slider, "format-value", (GCallback) fcut_format_value,
                NULL);

        hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
        gtk_box_pack_start ((GtkBox *) vbox, hbox, FALSE, FALSE, 0);

        gtk_box_pack_start ((GtkBox *) hbox, gtk_label_new(_("Presets:")), TRUE, FALSE, 0);

        button = preset_button(_("Default"), BS2B_DEFAULT_CLEVEL);
        gtk_box_pack_start ((GtkBox *) hbox, button, TRUE, FALSE, 0);

        button = preset_button("C. Moy", BS2B_CMOY_CLEVEL);
        gtk_box_pack_start ((GtkBox *) hbox, button, TRUE, FALSE, 0);

        button = preset_button("J. Meier", BS2B_JMEIER_CLEVEL);
        gtk_box_pack_start ((GtkBox *) hbox, button, TRUE, FALSE, 0);

        g_signal_connect (config_window, "response", (GCallback) gtk_widget_destroy, NULL);
        audgui_destroy_on_escape (config_window);

        gtk_widget_show_all (vbox);
    }

    gtk_window_present ((GtkWindow *) config_window);
}
Пример #28
0
void dsp_menu(GtkWidget *parent) {
  int i;

  parent_window=parent;

  dialog=gtk_dialog_new();
  gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(parent_window));
  gtk_window_set_decorated(GTK_WINDOW(dialog),FALSE);

  GdkRGBA color;
  color.red = 1.0;
  color.green = 1.0;
  color.blue = 1.0;
  color.alpha = 1.0;
  gtk_widget_override_background_color(dialog,GTK_STATE_FLAG_NORMAL,&color);

  GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(dialog));

  GtkWidget *grid=gtk_grid_new();
  gtk_grid_set_column_spacing (GTK_GRID(grid),10);
  //gtk_grid_set_row_spacing (GTK_GRID(grid),10);
  //gtk_grid_set_row_homogeneous(GTK_GRID(grid),TRUE);
  //gtk_grid_set_column_homogeneous(GTK_GRID(grid),TRUE);

  GtkWidget *close_b=gtk_button_new_with_label("Close DSP");
  g_signal_connect (close_b, "pressed", G_CALLBACK(close_cb), NULL);
  gtk_grid_attach(GTK_GRID(grid),close_b,0,0,1,1);

  GtkWidget *agc_hang_threshold_label=gtk_label_new("AGC Hang Threshold:");
  gtk_widget_show(agc_hang_threshold_label);
  gtk_grid_attach(GTK_GRID(grid),agc_hang_threshold_label,0,1,1,1);
  GtkWidget *agc_hang_threshold_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0.0, 100.0, 1.0);
  gtk_range_set_value (GTK_RANGE(agc_hang_threshold_scale),agc_hang_threshold);
  gtk_widget_show(agc_hang_threshold_scale);
  gtk_grid_attach(GTK_GRID(grid),agc_hang_threshold_scale,1,1,2,1);
  g_signal_connect(G_OBJECT(agc_hang_threshold_scale),"value_changed",G_CALLBACK(agc_hang_threshold_value_changed_cb),NULL);

  GtkWidget *pre_post_agc_label=gtk_label_new("NR/NR2/ANF");
  //gtk_widget_override_font(pre_post_agc_label, pango_font_description_from_string("Arial 18"));
  gtk_widget_show(pre_post_agc_label);
  gtk_grid_attach(GTK_GRID(grid),pre_post_agc_label,0,2,1,1);

  GtkWidget *pre_agc_b=gtk_radio_button_new_with_label(NULL,"Pre AGC");
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pre_agc_b),nr_agc==0);
  gtk_widget_show(pre_agc_b);
  gtk_grid_attach(GTK_GRID(grid),pre_agc_b,1,2,1,1);
  g_signal_connect(pre_agc_b,"pressed",G_CALLBACK(pre_post_agc_cb),(gpointer *)0);

  GtkWidget *post_agc_b=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(pre_agc_b),"Post AGC");
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (post_agc_b), nr_agc==1);
  gtk_widget_show(post_agc_b);
  gtk_grid_attach(GTK_GRID(grid),post_agc_b,2,2,1,1);
  g_signal_connect(post_agc_b,"pressed",G_CALLBACK(pre_post_agc_cb),(gpointer *)1);

  GtkWidget *nr2_gain_label=gtk_label_new("NR2 Gain Method");
  //gtk_widget_override_font(nr2_gain_label, pango_font_description_from_string("Arial 18"));
  gtk_widget_show(nr2_gain_label);
  gtk_grid_attach(GTK_GRID(grid),nr2_gain_label,0,3,1,1);

  GtkWidget *linear_b=gtk_radio_button_new_with_label(NULL,"Linear");
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (linear_b),nr2_gain_method==0);
  gtk_widget_show(linear_b);
  gtk_grid_attach(GTK_GRID(grid),linear_b,1,3,1,1);
  g_signal_connect(linear_b,"pressed",G_CALLBACK(nr2_gain_cb),(gpointer *)0);

  GtkWidget *log_b=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(linear_b),"Log");
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (log_b), nr2_gain_method==1);
  gtk_widget_show(log_b);
  gtk_grid_attach(GTK_GRID(grid),log_b,2,3,1,1);
  g_signal_connect(log_b,"pressed",G_CALLBACK(nr2_gain_cb),(gpointer *)1);

  GtkWidget *gamma_b=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(log_b),"Gamma");
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gamma_b), nr2_gain_method==2);
  gtk_widget_show(gamma_b);
  gtk_grid_attach(GTK_GRID(grid),gamma_b,3,3,1,1);
  g_signal_connect(gamma_b,"pressed",G_CALLBACK(nr2_gain_cb),(gpointer *)2);

  GtkWidget *nr2_npe_method_label=gtk_label_new("NR2 NPE Method");
  //gtk_widget_override_font(nr2_npe_method_label, pango_font_description_from_string("Arial 18"));
  gtk_widget_show(nr2_npe_method_label);
  gtk_grid_attach(GTK_GRID(grid),nr2_npe_method_label,0,4,1,1);

  GtkWidget *osms_b=gtk_radio_button_new_with_label(NULL,"OSMS");
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (osms_b),nr2_npe_method==0);
  gtk_widget_show(osms_b);
  gtk_grid_attach(GTK_GRID(grid),osms_b,1,4,1,1);
  g_signal_connect(osms_b,"pressed",G_CALLBACK(nr2_npe_method_cb),(gpointer *)0);

  GtkWidget *mmse_b=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(osms_b),"MMSE");
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mmse_b), nr2_npe_method==1);
  gtk_widget_show(mmse_b);
  gtk_grid_attach(GTK_GRID(grid),mmse_b,2,4,1,1);
  g_signal_connect(mmse_b,"pressed",G_CALLBACK(nr2_npe_method_cb),(gpointer *)1);

  GtkWidget *ae_b=gtk_check_button_new_with_label("NR2 AE Filter");
  //gtk_widget_override_font(ae_b, pango_font_description_from_string("Arial 18"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ae_b), nr2_ae);
  gtk_widget_show(ae_b);
  gtk_grid_attach(GTK_GRID(grid),ae_b,0,5,1,1);
  g_signal_connect(ae_b,"toggled",G_CALLBACK(ae_cb),NULL);

  gtk_container_add(GTK_CONTAINER(content),grid);

  sub_menu=dialog;

  gtk_widget_show_all(dialog);

}
Пример #29
0
void vi_cycle_bar_init(vi_cycle_bar_refresh_func_t refresh_func, void *user_data)
{
	char *m2s_images_path = "images";

	/* Allocate */
	vi_cycle_bar = calloc(1, sizeof(struct vi_cycle_bar_t));
	if (!vi_cycle_bar)
		fatal("%s: out of memory", __FUNCTION__);

	/* Initialize */
	vi_cycle_bar->refresh_func = refresh_func;
	vi_cycle_bar->refresh_func_arg = user_data;

	/* Icons */
	m2s_dist_file("back-single.png", m2s_images_path, m2s_images_path,
		cycle_bar_back_single_path, sizeof cycle_bar_back_single_path);
	m2s_dist_file("back-double.png", m2s_images_path, m2s_images_path,
		cycle_bar_back_double_path, sizeof cycle_bar_back_double_path);
	m2s_dist_file("back-triple.png", m2s_images_path, m2s_images_path,
		cycle_bar_back_triple_path, sizeof cycle_bar_back_triple_path);
	m2s_dist_file("forward-single.png", m2s_images_path, m2s_images_path,
		cycle_bar_forward_single_path, sizeof cycle_bar_forward_single_path);
	m2s_dist_file("forward-double.png", m2s_images_path, m2s_images_path,
		cycle_bar_forward_double_path, sizeof cycle_bar_forward_double_path);
	m2s_dist_file("forward-triple.png", m2s_images_path, m2s_images_path,
		cycle_bar_forward_triple_path, sizeof cycle_bar_forward_triple_path);
	m2s_dist_file("go.png", m2s_images_path, m2s_images_path,
		cycle_bar_go_path, sizeof cycle_bar_go_path);

	/* Buttons */
	GtkWidget *back_single_button = gtk_button_new();
	GtkWidget *back_double_button = gtk_button_new();
	GtkWidget *back_triple_button = gtk_button_new();
	GtkWidget *forward_single_button = gtk_button_new();
	GtkWidget *forward_double_button = gtk_button_new();
	GtkWidget *forward_triple_button = gtk_button_new();
	g_signal_connect(G_OBJECT(back_single_button), "clicked", G_CALLBACK(vi_cycle_bar_back_single_clicked_event), vi_cycle_bar);
	g_signal_connect(G_OBJECT(back_double_button), "clicked", G_CALLBACK(vi_cycle_bar_back_double_clicked_event), vi_cycle_bar);
	g_signal_connect(G_OBJECT(back_triple_button), "clicked", G_CALLBACK(vi_cycle_bar_back_triple_clicked_event), vi_cycle_bar);
	g_signal_connect(G_OBJECT(forward_single_button), "clicked", G_CALLBACK(vi_cycle_bar_forward_single_clicked_event), vi_cycle_bar);
	g_signal_connect(G_OBJECT(forward_double_button), "clicked", G_CALLBACK(vi_cycle_bar_forward_double_clicked_event), vi_cycle_bar);
	g_signal_connect(G_OBJECT(forward_triple_button), "clicked", G_CALLBACK(vi_cycle_bar_forward_triple_clicked_event), vi_cycle_bar);

	/* Scale */
	long long num_cycles = vi_state_get_num_cycles();
	GtkWidget *scale = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0, num_cycles, 1);
	gtk_widget_set_size_request(scale, 100, 32);
	gtk_scale_set_draw_value(GTK_SCALE(scale), FALSE);
	g_signal_connect(G_OBJECT(scale), "change-value", G_CALLBACK(vi_cycle_bar_change_value_event), vi_cycle_bar);
	vi_cycle_bar->scale = scale;


	/* Images */
	GtkWidget *back_single_image = gtk_image_new_from_file(cycle_bar_back_single_path);
	GtkWidget *back_double_image = gtk_image_new_from_file(cycle_bar_back_double_path);
	GtkWidget *back_triple_image = gtk_image_new_from_file(cycle_bar_back_triple_path);
	GtkWidget *forward_single_image = gtk_image_new_from_file(cycle_bar_forward_single_path);
	GtkWidget *forward_double_image = gtk_image_new_from_file(cycle_bar_forward_double_path);
	GtkWidget *forward_triple_image = gtk_image_new_from_file(cycle_bar_forward_triple_path);
	gtk_container_add(GTK_CONTAINER(back_single_button), back_single_image);
	gtk_container_add(GTK_CONTAINER(back_double_button), back_double_image);
	gtk_container_add(GTK_CONTAINER(back_triple_button), back_triple_image);
	gtk_container_add(GTK_CONTAINER(forward_single_button), forward_single_image);
	gtk_container_add(GTK_CONTAINER(forward_double_button), forward_double_image);
	gtk_container_add(GTK_CONTAINER(forward_triple_button), forward_triple_image);

	/* Table */
	GtkWidget *navigation_table = gtk_table_new(1, 7, FALSE);
	gtk_table_attach(GTK_TABLE(navigation_table), back_triple_button, 0, 1, 0, 1, 0, 0, 0, 0);
	gtk_table_attach(GTK_TABLE(navigation_table), back_double_button, 1, 2, 0, 1, 0, 0, 0, 0);
	gtk_table_attach(GTK_TABLE(navigation_table), back_single_button, 2, 3, 0, 1, 0, 0, 0, 0);
	gtk_table_attach(GTK_TABLE(navigation_table), scale, 3, 4, 0, 1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
	gtk_table_attach(GTK_TABLE(navigation_table), forward_single_button, 4, 5, 0, 1, 0, 0, 0, 0);
	gtk_table_attach(GTK_TABLE(navigation_table), forward_double_button, 5, 6, 0, 1, 0, 0, 0, 0);
	gtk_table_attach(GTK_TABLE(navigation_table), forward_triple_button, 6, 7, 0, 1, 0, 0, 0, 0);

	/* Label */
	GtkWidget *go_to_label = gtk_label_new("Current cycle:");
	gtk_misc_set_alignment(GTK_MISC(go_to_label), 0, 0.5);

	/* Go-to-cycle button */
	GtkWidget *go_to_button = gtk_button_new();
	GtkWidget *go_to_image = gtk_image_new_from_file(cycle_bar_go_path);
	gtk_container_add(GTK_CONTAINER(go_to_button), go_to_image);
	g_signal_connect(G_OBJECT(go_to_button), "clicked", G_CALLBACK(vi_cycle_bar_go_to_clicked_event), vi_cycle_bar);

	/* Go-to-cycle text entry */
	GtkWidget *go_to_entry = gtk_entry_new();
	gtk_entry_set_text(GTK_ENTRY(go_to_entry), "0");
	gtk_entry_set_width_chars(GTK_ENTRY(go_to_entry), 10);
	g_signal_connect(G_OBJECT(go_to_entry), "key-press-event", G_CALLBACK(cycle_bar_go_to_key_press_event), vi_cycle_bar);
	vi_cycle_bar->go_to_entry = go_to_entry;

	/* Table */
	GtkWidget *go_to_table = gtk_table_new(2, 2, FALSE);
	gtk_table_attach(GTK_TABLE(go_to_table), go_to_label, 0, 2, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
	gtk_table_attach(GTK_TABLE(go_to_table), go_to_entry, 0, 1, 1, 2, 0, 0, 0, 0);
	gtk_table_attach(GTK_TABLE(go_to_table), go_to_button, 1, 2, 1, 2, 0, 0, 0, 0);

	/* Spacer */
	GtkWidget *spacer = gtk_label_new("");
	gtk_widget_set_size_request(spacer, 5, -1);

	/* Horizontal box with the two tables */
	GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_box_pack_start(GTK_BOX(hbox), navigation_table, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(hbox), spacer, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(hbox), go_to_table, FALSE, FALSE, 0);

	/* Frame with everything */
	GtkWidget *frame = gtk_frame_new(NULL);
	gtk_container_add(GTK_CONTAINER(frame), hbox);

	/* Main widget */
	vi_cycle_bar->widget = frame;
}
Пример #30
0
// Основная функция построения класса, в которой происходит заполнение окна виджетами.
void cMainWin::Create()
{
	// Создаём объект, если ранее он был не создан или был уничтожен.
	if(mbIsCreated)
		return;


	// Общие виджеты. Будут использованы несколько раз.
	GtkWidget *awHBox;		// Горизонтальный бокс.
	GtkWidget *awVBox;		// Вертикальный бокс.
	GtkWidget *awLabel;		// Заголовок.
	GtkWidget *awFrame;		// Фрейм для виджетов.

	GtkWidget *awMenuBar;		// Виджет для основного меню.
	GtkWidget *awSubmenu;		// Подменю.
	GtkWidget *awMenuitem;		// Пункт основного меню.
	GtkWidget *awSubMenuitem;	// Пункт подменю.

	GtkWidget *awOpenFileButton;	// Кнопка открытия файла.
	GtkWidget *awAdditionButton;	// Кнопка доп. настроек.
	GtkWidget *awConvertButton;		// Кнопка конвертации.


	// Настраиваем виджет главного окна.
	mwWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_default_size ((GtkWindow *)mwWindow, 800, 400);	// Задаём размер.
	gtk_window_move((GtkWindow *)mwWindow, 50, 50);					// Перемещаем окно.
	gtk_window_set_title((GtkWindow *)mwWindow, msTitle.c_str());	// Задаём имя.

	// Устанавливаем обработчик события уничтожения окна.
	g_signal_connect(
			G_OBJECT(mwWindow), "delete_event",
			G_CALLBACK(gtk_main_quit), this);



	// Создаём новый вертикальный бокс и забиваем его в основное окно.
	mwMainBox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_container_add((GtkContainer *)mwWindow, mwMainBox);



	// Создаём новый виджет основного меню.
	awMenuBar = gtk_menu_bar_new ();
    gtk_box_pack_start (GTK_BOX (mwMainBox), awMenuBar, FALSE, TRUE, 0);	// Забиваем меню в главный бокс.


    // Создаём новый пункт меню Справка и заполняем его подменю.
    awMenuitem = gtk_menu_item_new_with_label ("Справка");
    awSubmenu = gtk_menu_new();


    // Добавляем в подменю новый пункт.
    awSubMenuitem = gtk_menu_item_new_with_label ("О программе");
    gtk_menu_shell_append (GTK_MENU_SHELL (awSubmenu), awSubMenuitem);	// Не забываем связать этот пункт с подменю.

    // Устанавливаем обработчик нажатия на пункт подменю.
    g_signal_connect(awSubMenuitem, "activate",
                                    G_CALLBACK(OnAbout), this);

    gtk_menu_item_set_submenu (GTK_MENU_ITEM (awMenuitem), awSubmenu);	// Связываем подменю с главным.
    gtk_menu_shell_append (GTK_MENU_SHELL (awMenuBar), awMenuitem);		// И добавляем пунтк меню в главное меню.


    // Добавляем в главный бокс разделитель виджетов(простая длинная линия).
    gtk_box_pack_start (GTK_BOX (mwMainBox), gtk_separator_new(GTK_ORIENTATION_HORIZONTAL), FALSE, TRUE, 5);


    // Задаём вертикальный бокс для первого пункта процесса конвертации и забиваем его в главный бокс.
	awVBox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_box_pack_start(GTK_BOX(mwMainBox), awVBox, FALSE, FALSE, 1);

	// Задаём горизонтальный бокс для первого пункта процесса конвертации и забиваем его в предыдущий вертикальный бокс.
	awHBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_box_pack_start(GTK_BOX(awVBox), awHBox, FALSE, FALSE, 1);

	// Задаём виджет для отображения текста и добавляем в горизонтальный бокс.
	awLabel = gtk_label_new ("1.");
	//gtk_widget_set_halign (awLabel, GTK_ALIGN_START); // Выравнивание. Не нужно, если использовать горизонтальный бокс.
	gtk_box_pack_start(GTK_BOX(awHBox), awLabel, FALSE, FALSE, 5);

	// Создаём кнопку Открыть файл и добавляем в горизонтальный бокс.
	awOpenFileButton = gtk_button_new_with_label ("Открыть файл");
	gtk_box_pack_start(GTK_BOX(awHBox), awOpenFileButton, FALSE, FALSE, 10);

	// Устанавливаем обработчик нажатия на кнопку Открыть файл.
    g_signal_connect(awOpenFileButton, "clicked",
    									G_CALLBACK(OnOpenFile), this);


    // Создаём бокс для списка всех записей и добавляем в горизонтальный бокс.
    mwTrackNameBox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    gtk_box_pack_start(GTK_BOX(awHBox), mwTrackNameBox, FALSE, FALSE, 5);


    // Переходим ко второму пункту меню
    // Задаём вертикальный бокс для второго пункта процесса конвертации и забиваем его в главный бокс.
	awVBox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_box_pack_start(GTK_BOX(mwMainBox), awVBox, FALSE, FALSE, 10);

	// Задаём горизонтальный бокс для второго пункта процесса конвертации и забиваем его в предыдущий вертикальный бокс.
	awHBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_box_pack_start(GTK_BOX(awVBox), awHBox, FALSE, FALSE, 1);

	// Задаём виджет для отображения текста и добавляем в горизонтальный бокс.
	awLabel = gtk_label_new ("2. ");
	gtk_box_pack_start(GTK_BOX(awHBox), awLabel, FALSE, FALSE, 5);


	// Создаём комбо бокс для выбора формата конвертации.
	mwFormat = gtk_combo_box_text_new ();
	for(int i = eFormat_MP3; i < eFormat_Unknown; i++)
	{
		// Для каждого пункта из enum добавляем пункт в комбо боксе со своим текстом из asFormat.
		gtk_combo_box_text_insert_text ((GtkComboBoxText *)mwFormat, -1, asFormat[i].c_str());
	}
	gtk_combo_box_set_active((GtkComboBox *)mwFormat, 0);	// Устанавливаем активный элемент на первый в списке.

	// Задаём обработчик события смены формата.
	g_signal_connect (mwFormat, "changed",
								G_CALLBACK (OnChangeFormat), this);

	gtk_box_pack_start(GTK_BOX(awHBox), mwFormat, FALSE, FALSE, 5);		// Добавляем комбо бокс в горизонтальный бокс.


	// Теперь настроим виджеты, которые будут соответствовать формату конвертации из комбо бокса.
	// Виджеты, соответствующие формату, будут показываться, только при выборе этого формата в комбо боксе.
	// Задаём горизонтальный бокс для настроек под определённый формат и добавляем его в вертикальный бокс.
	awHBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_box_pack_start(GTK_BOX(awVBox), awHBox, FALSE, FALSE, 10);

	// Настроим MP3 виджеты.
	// Задаём слайдер качества с определённым количеством меток.
	mMP3Widgets.mwQuality = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, eMP3Quality_count-1, 1);
	gtk_scale_set_draw_value ((GtkScale *)mMP3Widgets.mwQuality, FALSE);	// Не будем рисовать текущее значение.

	// Добавим метки на шкалу слайдера для визуализации.
	for(int i = 0; i < eMP3Quality_count; i++)
	{
		std::string asQ = asMP3Quality[i] +"kbps";	// Значения мток берём из asMP3Quality массива.
		gtk_scale_add_mark ((GtkScale *)mMP3Widgets.mwQuality, i, GTK_POS_TOP, asQ.c_str());
	}

	gtk_box_pack_start(GTK_BOX(awHBox), mMP3Widgets.mwQuality, TRUE, TRUE, 30);			// Добавляем слайдер в горизонтальный бокс.
	gtk_range_set_show_fill_level ((GtkRange *)mMP3Widgets.mwQuality, TRUE);			// Заполняем слайдер другим цветом.
	gtk_range_set_restrict_to_fill_level ((GtkRange *)mMP3Widgets.mwQuality, TRUE);		// Устанавливаем указатель слайдера до уровня заполнения слайдера.
	gtk_range_set_fill_level ((GtkRange *)mMP3Widgets.mwQuality, eMP3Quality_count-1);	// Полностью заполняем слайдер цветом.
	gtk_range_set_value ((GtkRange *)mMP3Widgets.mwQuality, eMP3Quality_count-1);		// Ставим значение слайдера на последнее из массива значений.

	// Указатель теперь связан с уровнем заполнения, но указатель всё ещё можно двигать, не меняя уровень заполнения.
	// Для этого необходимо ввести 2 обработчика событий - изменение значение слайдера и изменение границ указателя, для перемещения уровня заполнения.
	g_signal_connect (mMP3Widgets.mwQuality, "value-changed", G_CALLBACK (OnQualityChanged), this);
	g_signal_connect (mMP3Widgets.mwQuality, "adjust-bounds", G_CALLBACK (OnAdjustBoundsQuality), this);

	gtk_widget_show(mMP3Widgets.mwQuality);	// Показываем виджеты страницы MP3 конвертера.


	// Настраиваем OGG виджеты.
	// Задаём слайдер качества с определённым количеством меток.
	mOGGWidgets.mwQuality = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, eOGGQuality_count-1, 1);
	gtk_scale_set_draw_value ((GtkScale *)mOGGWidgets.mwQuality, FALSE);

	// Добавим метки на шкалу слайдера для визуализации.
	for(int i = 0; i < eOGGQuality_count; i++)
	{
		std::string asQ = asOGGQuality[i] +"kbps";	// Значения мток берём из asOGGQuality массива.
		gtk_scale_add_mark ((GtkScale *)mOGGWidgets.mwQuality, i, GTK_POS_TOP, asQ.c_str());
	}

	gtk_box_pack_start(GTK_BOX(awHBox), mOGGWidgets.mwQuality, TRUE, TRUE, 30);			// Добавляем слайдер в горизонтальный бокс.
	gtk_range_set_show_fill_level ((GtkRange *)mOGGWidgets.mwQuality, TRUE);			// Заполняем слайдер другим цветом.
	gtk_range_set_restrict_to_fill_level ((GtkRange *)mOGGWidgets.mwQuality, TRUE);		// Устанавливаем указатель слайдера до уровня заполнения слайдера.
	gtk_range_set_fill_level ((GtkRange *)mOGGWidgets.mwQuality, eOGGQuality_count-1);	// Полностью заполняем слайдер цветом.
	gtk_range_set_value ((GtkRange *)mOGGWidgets.mwQuality, eOGGQuality_count-1);		// Ставим значение слайдера на последнее из массива значений.

	// Снова вводим 2 обработчика событий, один на изменение значения слайдера и друго для изменения границ указателя, для перемещения уровня заполнения.
	g_signal_connect (mOGGWidgets.mwQuality, "value-changed", G_CALLBACK (OnQualityChanged), this);
	g_signal_connect (mOGGWidgets.mwQuality, "adjust-bounds", G_CALLBACK (OnAdjustBoundsQuality), this);


	// Добавим новую кнопку Дополнительно для отображения дополнительных параметров и добавим его в горизонтальный бокс.
	awAdditionButton = gtk_button_new_with_label ("Дополнительно");
	gtk_box_pack_end(GTK_BOX(awHBox), awAdditionButton, FALSE, FALSE, 30);

	// Введём обработчик нажатия на кнопку Дополнительно.
    g_signal_connect(awAdditionButton, "clicked",
    									G_CALLBACK(OnShowAdditionalSettings), this);


    // Переходим к третьему пункту меню.
    // Задаём вертикальный бокс для третьего пункта процесса конвертации и забиваем его в главный бокс.
	awVBox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_box_pack_start(GTK_BOX(mwMainBox), awVBox, FALSE, FALSE, 1);

	// Задаём горизонтальный бокс для третьего пункта процесса конвертации и забиваем его в предыдущий вертикальный бокс.
	awHBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_box_pack_start(GTK_BOX(awVBox), awHBox, FALSE, FALSE, 10);

	// Задаём виджет для отображения текста и добавляем в горизонтальный бокс.
	awLabel = gtk_label_new ("3.");
	gtk_box_pack_start(GTK_BOX(awHBox), awLabel, FALSE, FALSE, 5);


	// Добавим кнопку Конвертировать - для начала процесса конвертации ваших аудио файлов. Добавим кнопку в горизонтальный бокс.
	awConvertButton = gtk_button_new_with_label ("Конвертировать");
	gtk_box_pack_start(GTK_BOX(awHBox), awConvertButton, FALSE, FALSE, 10);

	// Создадим спиннер для визуального отображения процесса конвертации.
	// Это просто необходимо, т.к. программа как бы подвисает, из-за того что мы конвертируем в одном потоке с программой.
	// Серъёзно нагружает процессор =(
	mwSpinner = gtk_spinner_new ();
	gtk_box_pack_start(GTK_BOX(awHBox), mwSpinner, FALSE, FALSE, 5);


	// Обработчик события нажатие на кнопку Конвертация.
	g_signal_connect(awConvertButton, "clicked",
										G_CALLBACK(OnConvert), this);


	gtk_widget_show_all (mwWindow);	// Покажем все виджеты в окне.

	gtk_widget_hide(mOGGWidgets.mwQuality);	// Скроем виджеты со страницы OGG. По умолчанию отображаем конвертацию в MP3.
	gtk_widget_hide(mwSpinner);				// Скроем спиннер, т.к. мы хотим его показать только в момент конвертации файлов.


	mbIsCreated = true;	// Объект создан.
}