void signal_handler_cb (GtkWidget *widget, gpointer data)
{
	struct w_info *item = data;
	unsigned val;

	switch (item->type) {
		case CHECKBOX:
			val = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (widget));
			break;
		case BUTTON:
			val = 1;
			break;
		case SPINBUTTON:
			val = (unsigned) gtk_spin_button_get_value(GTK_SPIN_BUTTON (widget));
			break;
		case COMBOBOX:
			val = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
			break;
		default:
			return;
	}

	iio_device_debug_attr_write_longlong(dev, item->name, val);

	if (dev_slave)
		iio_device_debug_attr_write_longlong(dev_slave, item->name, val);

	if (!strcmp(item->name, "initialize")) {
		reload_settings();
	}
}
void
pidgin_stock_load_status_icon_theme(PidginStatusIconTheme *theme)
{
	GtkIconFactory *icon_factory;
	gint i;
	GtkIconSet *normal;
	GtkIconSet *translucent = NULL;
	GtkWidget *win;

	if (theme != NULL) {
		purple_prefs_set_string(PIDGIN_PREFS_ROOT "/status/icon-theme",
		                        purple_theme_get_name(PURPLE_THEME(theme)));
		purple_prefs_set_path(PIDGIN_PREFS_ROOT "/status/icon-theme-dir",
		                      purple_theme_get_dir(PURPLE_THEME(theme)));
	}
	else {
		purple_prefs_set_string(PIDGIN_PREFS_ROOT "/status/icon-theme", "");
		purple_prefs_set_path(PIDGIN_PREFS_ROOT "/status/icon-theme-dir", "");
	}

	icon_factory = gtk_icon_factory_new();

	gtk_icon_factory_add_default(icon_factory);

	win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_widget_realize(win);

	for (i = 0; i < G_N_ELEMENTS(sized_status_icons); i++)
	{
		normal = gtk_icon_set_new();
		if (sized_status_icons[i].translucent_name)
			translucent = gtk_icon_set_new();

#define ADD_SIZED_ICON(name, size) \
		if (sized_status_icons[i].name) { \
			add_sized_icon(normal, name, PIDGIN_ICON_THEME(theme), size, sized_status_icons[i], FALSE); \
			if (sized_status_icons[i].translucent_name) \
				add_sized_icon(translucent, name, PIDGIN_ICON_THEME(theme), size, sized_status_icons[i], TRUE); \
		}
		ADD_SIZED_ICON(microscopic, "11");
		ADD_SIZED_ICON(extra_small, "16");
		ADD_SIZED_ICON(small, "22");
		ADD_SIZED_ICON(medium, "32");
		ADD_SIZED_ICON(large, "48");
		ADD_SIZED_ICON(huge, "64");
#undef ADD_SIZED_ICON

		gtk_icon_factory_add(icon_factory, sized_status_icons[i].name, normal);
		gtk_icon_set_unref(normal);

		if (sized_status_icons[i].translucent_name) {
			gtk_icon_factory_add(icon_factory, sized_status_icons[i].translucent_name, translucent);
			gtk_icon_set_unref(translucent);
		}
	}

	gtk_widget_destroy(win);
	g_object_unref(G_OBJECT(icon_factory));
	reload_settings();
}
Exemple #3
0
ServerWidget::ServerWidget(xonotic::ConnectionDetails details, QWidget* parent)
    : QWidget(parent), connection(std::move(details))
{
    menu_quick_commands = new QMenu(tr("Quick Commands"), this);
    menu_quick_commands->setObjectName("menu_quick_commands");

    setupUi(this);
    button_refresh_status->setShortcut(QKeySequence::Refresh);
    button_refresh_cvars->setShortcut(QKeySequence::Refresh);

    delayed_status.setInterval(150); /// \todo read from settings?
    delayed_status.setSingleShot(true);
    connect(&delayed_status, &QTimer::timeout, this, &ServerWidget::request_status);

    init_status_table();

    init_cvar_table();

    init_player_table();

    init_console();

    init_connection();

    reload_settings();
}
static void signal_handler_cb (GtkWidget *widget, gpointer data)
{
	struct w_info *item = data;
	unsigned val;
	char str[80];
	int bit, ret;
	long long mask;

	switch (item->type) {
		case CHECKBOX:
			val = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (widget));
			break;
		case BUTTON:
			val = 1;
			break;
		case SPINBUTTON:
		case SPINBUTTON_S8:
			val = (unsigned) gtk_spin_button_get_value(GTK_SPIN_BUTTON (widget));
			break;
		case COMBOBOX:
			val = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
			break;
		case CHECKBOX_MASK:

			/* Format is: adi,gpo-manual-mode-enable-mask#2
			 * # separates item name from bit number
			 */
			val = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (widget));

			ret = sscanf(item->name, "%[^'#']#%d", str, &bit);
			if (ret != 2)
				return;

			iio_device_debug_attr_read_longlong(dev, str, &mask);

			if (val) {
				mask |= (1 << bit);
			} else {
				mask &= ~(1 << bit);
			}

			iio_device_debug_attr_write_longlong(dev, str, mask);

			if (dev_slave)
				iio_device_debug_attr_write_longlong(dev_slave, str, mask);
			return;
		default:
			return;
	}

	iio_device_debug_attr_write_longlong(dev, item->name, val);

	if (dev_slave)
		iio_device_debug_attr_write_longlong(dev_slave, item->name, val);

	if (!strcmp(item->name, "initialize")) {
		reload_settings();
	}
}
/**
 * @brief Loads settings.
 */
void MapEditor::load_settings() {

  ViewSettings& view = get_view_settings();
  Settings settings;

  view.set_grid_visible(
    settings.get_value_bool(Settings::map_grid_show_at_opening));
  view.set_grid_size(settings.get_value_size(Settings::map_grid_size));

  reload_settings();
}
void MainWindow::on_toolButton_clicked()
{
    int idx;
    EditDialog dialog(ui->comboBox->currentText(), this->settings);
    dialog.exec();
    idx = ui->comboBox->currentIndex();
    reload_settings();
    if (idx < ui->comboBox->maxVisibleItems() && idx >= 0) {
        ui->comboBox->setCurrentIndex(idx);
    } else if (ui->comboBox->maxVisibleItems() == 0) {
        ui->comboBox->setCurrentIndex(0);
    }
}
/**
 * @brief Loads settings.
 */
void SpriteEditor::load_settings() {

  ViewSettings& view = get_view_settings();
  EditorSettings settings;

  view.set_zoom(settings.get_value_double(EditorSettings::sprite_main_zoom));
  view.set_grid_visible(
    settings.get_value_bool(EditorSettings::sprite_grid_show_at_opening));
  view.set_grid_size(settings.get_value_size(EditorSettings::sprite_grid_size));

  ui.sprite_previewer->set_zoom(
    settings.get_value_double(EditorSettings::sprite_previewer_zoom));
  ui.sprite_previewer->set_show_origin(
    settings.get_value_bool(EditorSettings::sprite_origin_show_at_opening));

  reload_settings();
}
void MainWindow::on_toolButton_2_clicked()
{
    if (ui->comboBox->currentText().isEmpty() == false) {
        QMessageBox mbox;
        int ret;

        mbox.setText(QObject::tr("Are you sure you want to remove ") +
                     ui->comboBox->currentText() + "?");
        mbox.setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
        mbox.setDefaultButton(QMessageBox::Cancel);
        mbox.setButtonText(QMessageBox::Ok, tr("Remove"));

        ret = mbox.exec();
        if (ret == QMessageBox::Ok) {
            remove_server(settings, ui->comboBox->currentText());
            reload_settings();
        }
    }
}
static void
update_wm (GdkScreen *screen,
           gboolean   load_settings)
{
        int i;

        g_assert (n_mouse_modifiers > 0);

        if (current_wm != NULL) {
                g_signal_handlers_disconnect_by_func (G_OBJECT (current_wm),
                                                      G_CALLBACK (wm_settings_changed_callback),
                                                      NULL);
                current_wm = NULL;
                double_click_actions = NULL;
                n_double_click_actions = 0;
        }

        current_wm = mate_wm_manager_get_current (screen);

        if (current_wm != NULL) {
                g_signal_connect (G_OBJECT (current_wm), "settings_changed",
                                  G_CALLBACK (wm_settings_changed_callback), NULL);

                mate_window_manager_get_double_click_actions (current_wm,
                                                               &double_click_actions,
                                                               &n_double_click_actions);

        }

        for (i = 0; i < n_double_click_actions; i++) {
                gtk_combo_box_append_text (GTK_COMBO_BOX (double_click_titlebar_optionmenu),
                                           double_click_actions[i].human_readable_name);
        }

        if (load_settings)
                reload_settings ();
}
static void calibrate (gpointer button)
{
	GtkProgressBar *calib_progress;
	double rx_phase_lpc, rx_phase_hpc, tx_phase_hpc;
	long long cal_tone, cal_freq;
	int ret, samples;

	if (!cf_ad9361_lpc || !cf_ad9361_hpc) {
		printf("could not find capture cores\n");
		ret = -ENODEV;
		auto_calibrate = -1;
		goto calibrate_fail;
	}

	if (!dev_dds_master || !dev_dds_slave) {
		printf("could not find dds cores\n");
		ret = -ENODEV;
		auto_calibrate = -1;
		goto calibrate_fail;
	}

	calib_progress = GTK_PROGRESS_BAR(gtk_builder_get_object(builder, "progress_calibration"));
	set_calibration_progress(calib_progress, 0.00);

	mcs_cb(NULL, NULL);

	/*
	 * set some logical defaults / assumptions
	 */

	ret = default_dds(get_cal_tone(), CAL_SCALE);
	if (ret < 0) {
		printf("could not set dds cores\n");
		auto_calibrate = -1;
		goto calibrate_fail;
	}

	iio_channel_attr_read_longlong(dds_out[0][0], "frequency", &cal_tone);
	iio_channel_attr_read_longlong(dds_out[0][0], "sampling_frequency", &cal_freq);

	samples = get_cal_samples(cal_tone, cal_freq);

	DBG("cal_tone %u cal_freq %u samples %d", cal_tone, cal_freq, samples);

	gdk_threads_enter();
	osc_plot_set_sample_count(plot_xcorr_4ch, samples);
	osc_plot_draw_start(plot_xcorr_4ch);
	gdk_threads_leave();


	iio_device_attr_write(dev, "in_voltage_quadrature_tracking_en", "0");
	iio_device_attr_write(dev_slave, "in_voltage_quadrature_tracking_en", "0");

	trx_phase_rotation(cf_ad9361_lpc, 0.0);
	trx_phase_rotation(cf_ad9361_hpc, 0.0);
	set_calibration_progress(calib_progress, 0.16);

	/*
	 * Calibrate RX:
	 * 1 TX1B_B (HPC) -> RX1C_B (HPC) : BIST_LOOPBACK on A
	 */
	osc_plot_xcorr_revert(plot_xcorr_4ch, true);
	__cal_switch_ports_enable_cb(1);
	rx_phase_hpc = tune_trx_phase_offset(cf_ad9361_hpc, &ret, cal_freq, cal_tone, 1.0, 0.01, trx_phase_rotation);
	if (ret < 0) {
		printf("Failed to tune phase\n");
		auto_calibrate = -1;
		goto calibrate_fail;
	}
	set_calibration_progress(calib_progress, 0.40);
	DBG("rx_phase_hpc %f", rx_phase_hpc);

	/*
	 * Calibrate RX:
	 * 3 TX1B_B (HPC) -> RX1C_A (LPC) : BIST_LOOPBACK on B
	 */

	osc_plot_xcorr_revert(plot_xcorr_4ch, false);
	trx_phase_rotation(cf_ad9361_hpc, 0.0);
	__cal_switch_ports_enable_cb(3);
	rx_phase_lpc = tune_trx_phase_offset(cf_ad9361_lpc, &ret, cal_freq, cal_tone, 1.0, 0.01, trx_phase_rotation);
	if (ret < 0) {
		printf("Failed to tune phase\n");
		auto_calibrate = -1;
		goto calibrate_fail;
	}
	set_calibration_progress(calib_progress, 0.64);
	DBG("rx_phase_lpc %f", rx_phase_lpc);

	/*
	 * Calibrate TX:
	 * 4 TX1B_A (LPC) -> RX1C_A (LPC) : BIST_LOOPBACK on B
	 */

	osc_plot_xcorr_revert(plot_xcorr_4ch, false);
	trx_phase_rotation(cf_ad9361_hpc, 0.0);
	__cal_switch_ports_enable_cb(4);
	tx_phase_hpc = tune_trx_phase_offset(dev_dds_slave, &ret, cal_freq, cal_tone, -1.0 , 0.001, trx_phase_rotation);
	if (ret < 0) {
		printf("Failed to tune phase\n");
		auto_calibrate = -1;
		goto calibrate_fail;
	}
	set_calibration_progress(calib_progress, 0.88);
	DBG("tx_phase_hpc %f", tx_phase_hpc);

	trx_phase_rotation(cf_ad9361_hpc, rx_phase_hpc);

	gtk_range_set_value(GTK_RANGE(GTK_WIDGET(gtk_builder_get_object(builder,
			"tx_phase"))), scale_phase_0_360(tx_phase_hpc));

	ret = 0;
	set_calibration_progress(calib_progress, 1.0);

calibrate_fail:

	osc_plot_xcorr_revert(plot_xcorr_4ch, false);
	__cal_switch_ports_enable_cb(0);

	iio_device_attr_write(dev, "in_voltage_quadrature_tracking_en", "1");
	iio_device_attr_write(dev_slave, "in_voltage_quadrature_tracking_en", "1");

	gdk_threads_enter();
	reload_settings();

	create_blocking_popup(GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
			"FMCOMMS5", "Calibration finished %s",
			ret ? "with Error" : "Successfully");
	auto_calibrate = 1;

	osc_plot_destroy(plot_xcorr_4ch);
	if (button)
		gtk_widget_show(GTK_WIDGET(button));
	gdk_threads_leave();

	g_thread_exit(NULL);
}
void
pidgin_stock_load_stock_icon_theme(PidginStockIconTheme *theme)
{
	GtkIconFactory *icon_factory;
	gint i;
	GtkWidget *win;

	if (theme != NULL) {
		purple_prefs_set_string(PIDGIN_PREFS_ROOT "/stock/icon-theme",
		                        purple_theme_get_name(PURPLE_THEME(theme)));
		purple_prefs_set_path(PIDGIN_PREFS_ROOT "/stock/icon-theme-dir",
		                      purple_theme_get_dir(PURPLE_THEME(theme)));
	}
	else {
		purple_prefs_set_string(PIDGIN_PREFS_ROOT "/stock/icon-theme", "");
		purple_prefs_set_path(PIDGIN_PREFS_ROOT "/stock/icon-theme-dir", "");
	}

	icon_factory = gtk_icon_factory_new();

	gtk_icon_factory_add_default(icon_factory);

	win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_widget_realize(win);

	/* All non-sized icons */
	for (i = 0; i < G_N_ELEMENTS(stock_icons); i++) {
		GtkIconSource *source;
		GtkIconSet *iconset;
		gchar *filename;

		if (stock_icons[i].dir == NULL) {
			/* GTK+ Stock icon */
			iconset = gtk_style_lookup_icon_set(gtk_widget_get_style(win),
					stock_icons[i].filename);
		} else {
			filename = find_file(stock_icons[i].dir, stock_icons[i].filename);

			if (filename == NULL)
				continue;

			source = gtk_icon_source_new();
			gtk_icon_source_set_filename(source, filename);
			gtk_icon_source_set_direction_wildcarded(source, TRUE);
			gtk_icon_source_set_size_wildcarded(source, TRUE);
			gtk_icon_source_set_state_wildcarded(source, TRUE);

			iconset = gtk_icon_set_new();
			gtk_icon_set_add_source(iconset, source);

			gtk_icon_source_free(source);
			g_free(filename);
		}

		gtk_icon_factory_add(icon_factory, stock_icons[i].name, iconset);

		gtk_icon_set_unref(iconset);
	}

	/* All non-status sized icons */
	for (i = 0; i < G_N_ELEMENTS(sized_stock_icons); i++)
	{
		GtkIconSet *iconset = gtk_icon_set_new();

#define ADD_SIZED_ICON(name, size) \
		if (sized_stock_icons[i].name) \
			add_sized_icon(iconset, name, PIDGIN_ICON_THEME(theme), size, sized_stock_icons[i], FALSE);
		ADD_SIZED_ICON(microscopic, "11");
		ADD_SIZED_ICON(extra_small, "16");
		ADD_SIZED_ICON(small, "22");
		ADD_SIZED_ICON(medium, "32");
		ADD_SIZED_ICON(large, "48");
		ADD_SIZED_ICON(huge, "64");
#undef ADD_SIZED_ICON

		gtk_icon_factory_add(icon_factory, sized_stock_icons[i].name, iconset);
		gtk_icon_set_unref(iconset);
	}

	gtk_widget_destroy(win);
	g_object_unref(G_OBJECT(icon_factory));
	reload_settings();
}
static void calibrate (gpointer button)
{
	GtkProgressBar *calib_progress = NULL;
	double rx_phase_lpc, rx_phase_hpc, tx_phase_hpc;
	struct iio_channel *in0, *in0_slave;
	long long cal_tone, cal_freq;
	int ret, samples;

	in0 = iio_device_find_channel(dev, "voltage0", false);
	in0_slave = iio_device_find_channel(dev_slave, "voltage0", false);
	if (!in0 || !in0_slave) {
		printf("could not find channels\n");
		ret = -ENODEV;
		goto calibrate_fail;
	}

	if (!cf_ad9361_lpc || !cf_ad9361_hpc) {
		printf("could not find capture cores\n");
		ret = -ENODEV;
		goto calibrate_fail;
	}

	if (!dev_dds_master || !dev_dds_slave) {
		printf("could not find dds cores\n");
		ret = -ENODEV;
		goto calibrate_fail;
	}

	calib_progress = GTK_PROGRESS_BAR(gtk_builder_get_object(builder, "progress_calibration"));
	set_calibration_progress(calib_progress, 0.00);

	mcs_cb(NULL, NULL);

	/*
	 * set some logical defaults / assumptions
	 */

	ret = default_dds(get_cal_tone(), CAL_SCALE);
	if (ret < 0) {
		printf("could not set dds cores\n");
		goto calibrate_fail;
	}

	iio_channel_attr_read_longlong(dds_out[0][0], "frequency", &cal_tone);
	iio_channel_attr_read_longlong(dds_out[0][0], "sampling_frequency", &cal_freq);

	samples = get_cal_samples(cal_tone, cal_freq);

	DBG("cal_tone %lld cal_freq %lld samples %d", cal_tone, cal_freq, samples);

	gdk_threads_enter();
	osc_plot_set_sample_count(plot_xcorr_4ch, samples);
	osc_plot_draw_start(plot_xcorr_4ch);
	gdk_threads_leave();

	/* Turn off quadrature tracking while the sync is going on */
	iio_channel_attr_write(in0, "quadrature_tracking_en", "0");
	iio_channel_attr_write(in0_slave, "quadrature_tracking_en", "0");

	/* reset any Tx rotation to zero */
	trx_phase_rotation(cf_ad9361_lpc, 0.0);
	trx_phase_rotation(cf_ad9361_hpc, 0.0);
	set_calibration_progress(calib_progress, 0.16);

	/*
	 * Calibrate RX:
	 * 1 TX1B_B (HPC) -> RX1C_B (HPC) : BIST_LOOPBACK on A
	 */
	osc_plot_xcorr_revert(plot_xcorr_4ch, true);
	__cal_switch_ports_enable_cb(1);
	rx_phase_hpc = tune_trx_phase_offset(cf_ad9361_hpc, &ret, cal_freq, cal_tone, 1.0, 0.01, trx_phase_rotation);
	if (ret < 0) {
		printf("Failed to tune phase : %s:%i\n", __func__, __LINE__);
		goto calibrate_fail;
	}
	set_calibration_progress(calib_progress, 0.40);
	DBG("rx_phase_hpc %f", rx_phase_hpc);

	/*
	 * Calibrate RX:
	 * 3 TX1B_B (HPC) -> RX1C_A (LPC) : BIST_LOOPBACK on B
	 */

	osc_plot_xcorr_revert(plot_xcorr_4ch, false);
	trx_phase_rotation(cf_ad9361_hpc, 0.0);
	__cal_switch_ports_enable_cb(3);
	rx_phase_lpc = tune_trx_phase_offset(cf_ad9361_lpc, &ret, cal_freq, cal_tone, 1.0, 0.01, trx_phase_rotation);
	if (ret < 0) {
		printf("Failed to tune phase : %s:%i\n", __func__, __LINE__);
		goto calibrate_fail;
	}
	set_calibration_progress(calib_progress, 0.64);

	(void) rx_phase_lpc; /* Avoid compiler warnings */
	DBG("rx_phase_lpc %f", rx_phase_lpc);

	/*
	 * Calibrate TX:
	 * 4 TX1B_A (LPC) -> RX1C_A (LPC) : BIST_LOOPBACK on B
	 */

	osc_plot_xcorr_revert(plot_xcorr_4ch, false);
	trx_phase_rotation(cf_ad9361_hpc, 0.0);
	__cal_switch_ports_enable_cb(4);
	tx_phase_hpc = tune_trx_phase_offset(dev_dds_slave, &ret, cal_freq, cal_tone, -1.0 , 0.001, trx_phase_rotation);
	if (ret < 0) {
		printf("Failed to tune phase : %s:%i\n", __func__, __LINE__);
		goto calibrate_fail;
	}
	set_calibration_progress(calib_progress, 0.88);
	DBG("tx_phase_hpc %f", tx_phase_hpc);

	trx_phase_rotation(cf_ad9361_hpc, rx_phase_hpc);

	gtk_range_set_value(GTK_RANGE(GTK_WIDGET(gtk_builder_get_object(builder,
			"tx_phase"))), scale_phase_0_360(tx_phase_hpc));

	ret = 0;
	set_calibration_progress(calib_progress, 1.0);

calibrate_fail:

	osc_plot_xcorr_revert(plot_xcorr_4ch, false);
	__cal_switch_ports_enable_cb(0);

	if (in0 && in0_slave) {
		iio_channel_attr_write(in0, "quadrature_tracking_en", "1");
		iio_channel_attr_write(in0_slave, "quadrature_tracking_en", "1");
	}

	gdk_threads_enter();
	reload_settings();

	if (ret) {
		create_blocking_popup(GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
			"FMCOMMS5", "Calibration failed");
		auto_calibrate = -1;
	} else {
		/* set completed flag for testing */
		auto_calibrate = 1;
	}

	osc_plot_destroy(plot_xcorr_4ch);
	if (button)
		gtk_widget_show(GTK_WIDGET(button));
	gdk_threads_leave();

	/* reset progress bar */
	gtk_progress_bar_set_fraction(calib_progress, 0.0);
	gtk_progress_bar_set_text(calib_progress, "Calibration Progress");

	/* Disable the channels that were enabled at the beginning of the calibration */
	struct iio_device *iio_dev;
	iio_dev = iio_context_find_device(get_context_from_osc(), CAP_DEVICE_ALT);
	if (iio_dev && cap_device_channels_enabled) {
		iio_channels_change_shadow_of_enabled(iio_dev, false);
		cap_device_channels_enabled = false;
	}

	g_thread_exit(NULL);
}
void MainWindow::set_settings(QSettings * s)
{
    this->settings = s;
    reload_settings();
};
int
main (int argc, char **argv)
{
        GdkScreen *screen;
	MateWMSettings new_settings;
        GtkBuilder *builder;
        GError *error = NULL;
	int rc = 0;
        int i;

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

        gtk_init (&argc, &argv);

        mate_wm_manager_init ();

        screen = gdk_display_get_default_screen (gdk_display_get_default ());

        current_wm = mate_wm_manager_get_current (screen);

        if (current_wm == NULL) {
                try_spawn_config_tool (screen);
                goto out;
        }

        builder = gtk_builder_new ();
        gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);

        if (gtk_builder_add_from_file (builder, UIDIR "/mate-window-properties.ui", &error) == 0) {
                g_warning ("Could not parse UI file: %s", error->message);
                g_error_free (error);
                g_object_unref (builder);
                rc = 1;
                goto out;
        }

        dialog_win = GTK_WIDGET (gtk_builder_get_object (builder,
                                                         "main-dialog"));
        focus_mode_checkbutton = gtk_builder_get_object (builder,
                                                         "focus-mode-checkbutton");
        autoraise_checkbutton = gtk_builder_get_object (builder,
                                                        "autoraise-checkbutton");
        autoraise_delay_slider = gtk_builder_get_object (builder,
                                                         "autoraise-delay-slider");
        autoraise_delay_hbox = GTK_WIDGET (gtk_builder_get_object (builder,
                                                                   "autoraise-delay-hbox"));
        double_click_titlebar_optionmenu = gtk_builder_get_object (builder,
                                                                   "double-click-titlebar-optionmenu");
        alt_click_hbox = gtk_builder_get_object (builder, "alt-click-box");

        gtk_range_set_range (GTK_RANGE (autoraise_delay_slider),
                             0, 10);

        gtk_range_set_increments (GTK_RANGE (autoraise_delay_slider),
                                  0.2, 1.0);

        new_settings.flags = 0;
        init_settings_struct (&new_settings);
	settings = mate_wm_settings_copy (&new_settings);

        reload_mouse_modifiers ();
        update_wm (screen, FALSE);

        set_alt_click_value (&new_settings);
        gtk_range_set_value (GTK_RANGE (autoraise_delay_slider),
                             new_settings.autoraise_delay / 1000.0);
        gtk_combo_box_set_active (GTK_COMBO_BOX (double_click_titlebar_optionmenu),
                                  new_settings.double_click_action);

        reload_settings (); /* must come before below signal connections */

        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 (focus_mode_checkbutton, "toggled",
                          G_CALLBACK (mouse_focus_toggled_callback), NULL);

        g_signal_connect (autoraise_checkbutton, "toggled",
                          G_CALLBACK (autoraise_toggled_callback), NULL);

        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 (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;
        }

        capplet_set_icon (dialog_win, "preferences-system-windows");
        gtk_widget_show (dialog_win);

        gtk_main ();

        g_object_unref (builder);

out:
        return rc;
}
static void
wm_settings_changed_callback (MateWindowManager *wm,
                              void               *data)
{
        reload_settings ();
}