コード例 #1
0
ファイル: init_texmacs.cpp プロジェクト: xywei/texmacs
void
setup_texmacs () {
  url settings_file= "$TEXMACS_HOME_PATH/system/settings.scm";
  debug_boot << "Welcome to TeXmacs " TEXMACS_VERSION "\n";
  debug_boot << HRULE;

  set_setting ("VERSION", TEXMACS_VERSION);
  setup_tex ();
  setup_inkscape_extension ();
  
  string s= scheme_tree_to_block (texmacs_settings);
  //cout << "settings_t= " << texmacs_settings << "\n";
  //cout << "settings_s= " << s << "\n";
  if (save_string (settings_file, s) || load_string (settings_file, s, false)) {
    failed_error << HRULE;
    failed_error << "I could not save or reload the file\n\n";
    failed_error << "\t" << settings_file << "\n\n";
    failed_error << "Please give me full access control over this file and\n";
    failed_error << "rerun 'TeXmacs'.\n";
    failed_error << HRULE;
    FAILED ("unable to write settings");
  }
  
  debug_boot << HRULE;
  debug_boot << "Installation completed successfully !\n";
  debug_boot << "I will now start up the editor\n";
  debug_boot << HRULE;
}
コード例 #2
0
ファイル: stress-timer.c プロジェクト: ColinIanKing/stress-ng
static int stress_set_timer_rand(const char *opt)
{
	bool timer_rand = true;

	(void)opt;
	return set_setting("timer-rand", TYPE_ID_BOOL, &timer_rand);
}
コード例 #3
0
static int stress_set_stream_index(const char *opt)
{
	uint32_t stream_index;

	stream_index = get_int32(opt);
	check_range("stream-index", stream_index, 0, 3);
	return set_setting("stream-index", TYPE_ID_UINT32, &stream_index);
}
コード例 #4
0
static int stress_set_mremap_bytes(const char *opt)
{
	size_t mremap_bytes;

	mremap_bytes = (size_t)get_uint64_byte_memory(opt, 1);
	check_range_bytes("mremap-bytes", mremap_bytes,
		MIN_MREMAP_BYTES, MAX_MEM_LIMIT);
	return set_setting("mremap-bytes", TYPE_ID_SIZE_T, &mremap_bytes);
}
コード例 #5
0
static int stress_set_splice_bytes(const char *opt)
{
	size_t splice_bytes;

	splice_bytes = (size_t)get_uint64_byte_memory(opt, 1);
	check_range_bytes("splice-bytes", splice_bytes,
		MIN_SPLICE_BYTES, MAX_MEM_LIMIT);
	return set_setting("splice-bytes", TYPE_ID_SIZE_T, &splice_bytes);
}
コード例 #6
0
static int stress_set_aio_linux_requests(const char *opt)
{
	uint64_t aio_linux_requests;

	aio_linux_requests = get_uint32(opt);
	check_range("aiol-requests", aio_linux_requests,
		MIN_AIO_LINUX_REQUESTS, MAX_AIO_LINUX_REQUESTS);
	return set_setting("aiol-requests", TYPE_ID_UINT64, &aio_linux_requests);
}
コード例 #7
0
/*
 *  stress_set_lsearch_size()
 *      set lsearch size from given option string
 */
static int stress_set_lsearch_size(const char *opt)
{
	uint64_t lsearch_size;

	lsearch_size = get_uint64(opt);
	check_range("lsearch-size", lsearch_size,
		MIN_TSEARCH_SIZE, MAX_TSEARCH_SIZE);
	return set_setting("lsearch-size", TYPE_ID_UINT64, &lsearch_size);
}
コード例 #8
0
/*
 *  stress_set_mergesort_size()
 *	set mergesort size
 */
static int stress_set_mergesort_size(const char *opt)
{
	uint64_t mergesort_size;

	mergesort_size = get_uint64(opt);
	check_range("mergesort-size", mergesort_size,
		MIN_MERGESORT_SIZE, MAX_MERGESORT_SIZE);
	return set_setting("mergesort-size", TYPE_ID_UINT64, &mergesort_size);
}
コード例 #9
0
ファイル: stress-lease.c プロジェクト: ColinIanKing/stress-ng
static int stress_set_lease_breakers(const char *opt)
{
	uint64_t lease_breakers;

	lease_breakers = get_uint64(opt);
	check_range("lease-breakers", lease_breakers,
		MIN_LEASE_BREAKERS, MAX_LEASE_BREAKERS);
	return set_setting("lease-breakers", TYPE_ID_UINT64, &lease_breakers);
}
コード例 #10
0
static int stress_set_stream_L3_size(const char *opt)
{
	uint64_t stream_L3_size;

	stream_L3_size = get_uint64_byte(opt);
	check_range_bytes("stream-L3-size", stream_L3_size,
		MIN_STREAM_L3_SIZE, MAX_STREAM_L3_SIZE);
	return set_setting("stream-L3-size", TYPE_ID_UINT64, &stream_L3_size);
}
コード例 #11
0
ファイル: stress-timer.c プロジェクト: ColinIanKing/stress-ng
/*
 *  stress_set_timer_freq()
 *	set timer frequency from given option
 */
static int stress_set_timer_freq(const char *opt)
{
	uint64_t timer_freq;

	timer_freq = get_uint64(opt);
	check_range("timer-freq", timer_freq,
		MIN_TIMER_FREQ, MAX_TIMER_FREQ);
	return set_setting("timer-freq", TYPE_ID_UINT64, &timer_freq);
}
コード例 #12
0
static int stress_set_fallocate_bytes(const char *opt)
{
	off_t fallocate_bytes;

	fallocate_bytes = (off_t)get_uint64_byte_filesystem(opt, 1);
	check_range_bytes("fallocate-bytes", fallocate_bytes,
		MIN_FALLOCATE_BYTES, MAX_FALLOCATE_BYTES);
	return set_setting("fallocate-bytes", TYPE_ID_OFF_T, &fallocate_bytes);
}
コード例 #13
0
static int stress_set_sync_file_bytes(const char *opt)
{
	off_t sync_file_bytes;

	sync_file_bytes = (off_t)get_uint64_byte_filesystem(opt, 1);
	check_range_bytes("sync_file-bytes", sync_file_bytes,
		MIN_SYNC_FILE_BYTES, MAX_SYNC_FILE_BYTES);
	return set_setting("sync_file-bytes", TYPE_ID_OFF_T, &sync_file_bytes);
}
コード例 #14
0
static int stress_set_sendfile_size(const char *opt)
{
	int64_t sendfile_size;

	sendfile_size = get_uint64_byte(opt);
	check_range_bytes("sendfile-size", sendfile_size,
		MIN_SENDFILE_SIZE, MAX_SENDFILE_SIZE);
	return set_setting("sendfile-size", TYPE_ID_UINT64, &sendfile_size);
}
コード例 #15
0
static int stress_set_userfaultfd_bytes(const char *opt)
{
	size_t userfaultfd_bytes;

	userfaultfd_bytes = (size_t)get_uint64_byte_memory(opt, 1);
	check_range_bytes("userfaultfd-bytes", userfaultfd_bytes,
		MIN_MMAP_BYTES, MAX_MEM_LIMIT);
	return set_setting("userfaultfd-bytes", TYPE_ID_SIZE_T, &userfaultfd_bytes);
}
コード例 #16
0
ファイル: stress-sem.c プロジェクト: ColinIanKing/stress-ng
static int stress_set_semaphore_posix_procs(const char *opt)
{
	uint64_t semaphore_posix_procs;

	semaphore_posix_procs = get_uint64(opt);
	check_range("sem-procs", semaphore_posix_procs,
		MIN_SEMAPHORE_PROCS, MAX_SEMAPHORE_PROCS);
	return set_setting("sem-procs", TYPE_ID_UINT64, &semaphore_posix_procs);
}
コード例 #17
0
static int stress_set_stream_madvise(const char *opt)
{
	const stream_madvise_info_t *info;

	for (info = stream_madvise_info; info->name; info++) {
		if (!strcmp(opt, info->name)) {
			set_setting("stream-madvise", TYPE_ID_INT, &info->advice);
			return 0;
		}
	}
	(void)fprintf(stderr, "invalid stream-madvise advice '%s', allowed advice options are:", opt);
	for (info = stream_madvise_info; info->name; info++) {
		(void)fprintf(stderr, " %s", info->name);
        }
	(void)fprintf(stderr, "\n");
	return -1;
}
コード例 #18
0
/*
 *  stress_set_memthrash_method()
 *	set the default memthresh method
 */
static int stress_set_memthrash_method(const char *name)
{
	size_t i;

	for (i = 0; i < SIZEOF_ARRAY(memthrash_methods); i++) {
		const stress_memthrash_method_info_t *info = &memthrash_methods[i];
		if (!strcmp(memthrash_methods[i].name, name)) {
			set_setting("memthrash-method", TYPE_ID_UINTPTR_T, &info);
			return 0;
		}
	}

	(void)fprintf(stderr, "memthrash-method must be one of:");
	for (i = 0; i < SIZEOF_ARRAY(memthrash_methods); i++) {
		(void)fprintf(stderr, " %s", memthrash_methods[i].name);
	}
	(void)fprintf(stderr, "\n");

	return -1;
}
コード例 #19
0
ファイル: ui_gtk.c プロジェクト: japeq/japlay
static void add_cb(GtkButton *button, gpointer ptr)
{
	GtkWidget *dialog;

	UNUSED(button);
	UNUSED(ptr);

	struct playlist_page *page = page_playlist();
	if (page->playlist == japlay_queue ||
	    page->playlist == japlay_history) {
		ui_error("Can not add files to this playlist.\n\nPlease select a main or a custom playlist.\n");
		return;
	}

	dialog = gtk_file_chooser_dialog_new("Add Files",
		GTK_WINDOW(main_window), GTK_FILE_CHOOSER_ACTION_OPEN,
		GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
		GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
		NULL);
	gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), true);
	const char *path = get_setting("file_chooser_path");
	if (path) {
		gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),
						    path);
	}

	if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
		char *path = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(dialog));
		if (path) {
			set_setting("file_chooser_path", path);
			free(path);
		}
		GSList *filelist = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
		g_slist_foreach(filelist, (GFunc)add_one_file, NULL);
		g_slist_free(filelist);
	}
	gtk_widget_destroy(dialog);
}
コード例 #20
0
ファイル: ui_gtk.c プロジェクト: japeq/japlay
static void add_dir_cb(GtkMenuItem *menuitem, gpointer ptr)
{
	GtkWidget *dialog;

	UNUSED(menuitem);
	UNUSED(ptr);

	struct playlist_page *page = page_playlist();
	if (page->playlist == japlay_queue ||
	    page->playlist == japlay_history) {
		ui_error("Can not add files to this playlist.\n\nPlease select a main or a custom playlist.\n");
		return;
	}

	dialog = gtk_file_chooser_dialog_new("Add directory",
		GTK_WINDOW(main_window), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
		GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
		GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
		NULL);
	const char *path = get_setting("file_chooser_path");
	if (path) {
		gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),
						    path);
	}

	if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
		char *path = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(dialog));
		if (path) {
			set_setting("file_chooser_path", path);
			free(path);
		}
		char *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
		add_dir_or_file_playlist(page->playlist, filename);
		g_free(filename);
	}
	gtk_widget_destroy(dialog);
}
コード例 #21
0
ファイル: interface_win32.c プロジェクト: rscarson/Lavendeux
    /** 
     * Prepare and draw the interface 
     * @param exit_callback Method to be called in event of a quit
     * @param parse_callback Method to be called in event of the hotkeys being pressed
     */
    void init_interface(exitCallback exit_callback, parseCallback parse_callback) {
        int i;
        HICON hIcon;
        HINSTANCE hInstance;
        WNDCLASSEX hClass;

        /* Callback methods */
        _parse_callback = parse_callback;
        _exit_callback = exit_callback;

        /* Init equation stores */
        for (i=0; i<MAX_EQUATIONS; ++i)
            stored_entries[i] = NULL;

        /* No default path yet */
        prefered_path[0] = '\0';

        /* Get module instance */
        hInstance = GetModuleHandle(NULL);
        if (!hInstance)
            error_msg(L"Error while starting", L"Cannot get handle to module", 1);

        /* Load icon */
        hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(ICON_ID)); 
        if (!hIcon) {
            exit(EXIT_FAILURE);
        }

        /* Register class */
        hClass.cbSize         = sizeof(hClass);
        hClass.style          = CS_HREDRAW | CS_VREDRAW;
        hClass.lpfnWndProc    = wnd_callback;
        hClass.cbClsExtra     = 0;
        hClass.cbWndExtra     = 0;
        hClass.hInstance      = hInstance;
        hClass.hIcon          = hIcon;
        hClass.hCursor        = LoadCursor(NULL, IDC_ARROW);
        hClass.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
        hClass.lpszMenuName   = 0;
        hClass.lpszClassName  = WINDOW_CALLBACK;
        hClass.hIconSm        = hIcon;
        RegisterClassEx(&hClass);

        /* Create the window */
        hWnd = CreateWindowEx(0, WINDOW_CALLBACK, APPLICATION_NAME, 0, 0, 0, 0, 0, NULL, NULL, hInstance, NULL);
        if (GetLastError() != 0)
            error_msg(L"Error while starting", L"Cannot get handle to window", 1);

        if (get_setting(SETTING_HOTMOD) == 0 || get_setting(SETTING_HOTKEY) == 0) {
            set_setting(SETTING_HOTMOD, MOD_CONTROL);
            set_setting(SETTING_HOTKEY, VK_SPACE);
        }

        /* Register hotkey */
        if (!RegisterHotKey(hWnd, HOTKEY_ID, get_setting(SETTING_HOTMOD), get_setting(SETTING_HOTKEY)))
            error_msg(L"Error while starting", L"Cannot register hotkey. Is Lavendeux already running?", 1);

        /* Start window */
        ShowWindow(hWnd, 0);
        UpdateWindow(hWnd);

        /* Populate notification data */
        nid.cbSize = sizeof(nid);
        nid.hWnd = hWnd;
        nid.uID = 100;
        nid.uFlags = NIF_INFO | NIF_ICON | NIF_TIP | NIF_MESSAGE;
        nid.uCallbackMessage = RegisterWindowMessage(WINDOW_CALLBACK);
        nid.hIcon = hIcon;
        nid.dwInfoFlags = NIIF_INFO;
        strcpy(nid.szTip, APPLICATION_NAME);
        if (get_setting(SETTING_SILENTSTART) == SETTING_SILENTSTART_OFF) {
            nid.uFlags |= NIF_INFO;
            strcpy(nid.szInfoTitle, RUNNING_TITLE);
            strcpy(nid.szInfo, RUNNING_MSG);
        }

        /* Add notification icon to tray */
        Shell_NotifyIcon(NIM_ADD, &nid);
        DestroyIcon(hIcon);
    }
コード例 #22
0
ファイル: lighthouse.c プロジェクト: infokiller/lighthouse
/* @brief Initializes the settings global structure and read in the configuration
 *        file.
 * 
 * Note: this function does not initialize settings.screen_* data.
 *
 * @return Void.
 */
static int initialize_settings(char *config_file) {
  /* Set default settings. */
  settings.query_fg.r = settings.highlight_fg.r = 0.1;
  settings.query_fg.g = settings.highlight_fg.g = 0.1;
  settings.query_fg.b = settings.highlight_fg.b = 0.1;
  settings.result_fg.r = 0.5;
  settings.result_fg.g = 0.5;
  settings.result_fg.b = 0.5;
  settings.query_bg.r = settings.result_bg.r = settings.highlight_bg.r = 1.0;
  settings.query_bg.g = settings.result_bg.g = settings.highlight_bg.g = 1.0;
  settings.query_bg.b = settings.result_bg.b = settings.highlight_bg.b = 1.0;
  settings.font_size = FONT_SIZE;
  settings.horiz_padding = HORIZ_PADDING;
  settings.cursor_padding = CURSOR_PADDING;
  settings.max_height = MAX_HEIGHT;
  settings.height = HEIGHT;
  settings.width = WIDTH;
  settings.x = HALF_PERCENT;
  settings.y = HALF_PERCENT;
  settings.desktop = 0xFFFFFFFF;
  settings.screen = 0;
  settings.backspace_exit = 1;

  /* Read in from the config file. */
  wordexp_t expanded_file;
  if (wordexp(config_file, &expanded_file, 0)) {
    fprintf(stderr, "Error expanding file %s\n", config_file);
  } else {
    config_file = expanded_file.we_wordv[0];
  }

  size_t ret = 0;
  int32_t fd = open(config_file, O_RDONLY);
  if (fd == -1) {
    fprintf(stderr, "Couldn't open config file %s: %s\n", config_file, strerror(errno));
    return 1;
  } else {
    ret = read(fd, global.config_buf, sizeof(global.config_buf));
  }

  int32_t i, mode;
  mode = 1; /* 0 looking for param. 1 looking for value. 2 skipping chars */
  char *curr_param = global.config_buf;
  char *curr_val = NULL;
  for (i = 0; i < ret; i++) {
    switch (global.config_buf[i]) {
      case '=':
        global.config_buf[i] = '\0';
        mode = 1; /* Now we get the value. */
        break;
      case '\n':
        global.config_buf[i] = '\0';
        set_setting(curr_param, curr_val);
        mode = 0; /* Now we look for a new param. */
        break;
      default:
        if (mode == 0) {
          curr_param = &global.config_buf[i];
        } else if (mode == 1) {
          curr_val = &global.config_buf[i];
        }
        mode = 2;
        break;
    }
  }
  return 0;
}
コード例 #23
0
ファイル: interface_win32.c プロジェクト: rscarson/Lavendeux
    /**
     * Prepare to register a new hothey
     */
    void key_registrar( void ) {
        HINSTANCE hInstance;
        WNDCLASSEX wcex;
        MSG msg;
        int modifiers = 0;
        char text[256];
        char buffer[256];
        unsigned char lpKeyState[256];
        hInstance = GetModuleHandle(NULL);

        /* Register dialog class */
        wcex.cbSize = sizeof(WNDCLASSEX);
        wcex.style          = CS_HREDRAW | CS_VREDRAW;
        wcex.lpfnWndProc    = key_callback;
        wcex.cbClsExtra     = 0;
        wcex.cbWndExtra     = 0;
        wcex.hInstance      = hInstance;
        wcex.hIcon          = LoadIcon(hInstance, MAKEINTRESOURCE(ICON_ID));
        wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
        wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
        wcex.lpszMenuName   = NULL;
        wcex.lpszClassName  = HOTKEY_CALLBACK;
        wcex.hIconSm        = LoadIcon(hInstance, MAKEINTRESOURCE(ICON_ID));
        if (!RegisterClassEx(&wcex))
            error_msg(L"Error loading window", L"Can't register class", 1);

        /* Create window */
        hDlg = CreateWindow(
            HOTKEY_CALLBACK,
            _T("Hotkey selection"),
            WS_OVERLAPPEDWINDOW ^ WS_THICKFRAME ^ WS_MAXIMIZEBOX,
            CW_USEDEFAULT, CW_USEDEFAULT,
            500, 100,
            NULL,
            NULL,
            hInstance,
            NULL
        );
        if (!hDlg)
            error_msg(L"Error loading window", L"Can't create window", 1);

        /* Add a text element */
        hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "static", "ST_U", 
            WS_CHILD | WS_VISIBLE | SS_CENTER, 
            0, 0, 500, 100, hDlg, NULL, hInstance, NULL);
        if (!hEdit)
            error_msg(L"Error loading window", L"Can't create label", 1);

        /* Start the dialog */
        if (!hotkey_name(get_setting(SETTING_HOTMOD), get_setting(SETTING_HOTKEY), buffer))
            error_msg(L"Error loading window", L"Invalid hotkey! Try running with the -n flag to restore defaults!", 1);
        sprintf(text, "\nCurrent hotkey is %s\nPlease enter the new hotkey", buffer);
        SetWindowText(hEdit, _T(text));
        ShowWindow(hDlg, SW_SHOW);
        UpdateWindow(hDlg);

        /* Message loop */
        while (GetMessage(&msg, NULL, 0, 0)) {
            /* Close if done */
            if (!GetClassInfoEx(hInstance, HOTKEY_CALLBACK, &wcex))
                return;

            GetKeyboardState(lpKeyState);


            /* Get modifiers */
            if (lpKeyState[VK_SHIFT]>1) {
                modifiers |= MOD_SHIFT;
            } 
            if (lpKeyState[VK_CONTROL]>1) {
                modifiers |= MOD_CONTROL;
            } 
            if (lpKeyState[VK_MENU]>1) {
                modifiers |= MOD_ALT;
            }

            /* Don't do this if we don't need to */
            if (modifiers != 0) {
                for (int i=0x01; i<0xFF; i++) {
                    /* Skip useless cases */
                    if (i == VK_SHIFT || i == VK_CONTROL || i == VK_MENU || 
                        i == VK_LSHIFT || i == VK_LCONTROL || i == VK_LMENU || 
                        i == VK_RSHIFT || i == VK_RCONTROL || i == VK_RMENU
                    ) continue;

                    /* If pressed */
                    if (lpKeyState[i]>1) {
                        if (!hotkey_name(modifiers, i, buffer))
                            continue;
                        sprintf(text, "\nHotkey set to %s", buffer);


                        /* Unregister old hotkey */
                        UnregisterHotKey(hWnd, HOTKEY_ID);

                        /* New hotkey */
                        if (!RegisterHotKey(hWnd, HOTKEY_ID, modifiers, i)) {
                            if (!RegisterHotKey(hWnd, HOTKEY_ID, MOD_CONTROL, VK_SPACE))
                                error_msg(L"Runtime Error", L"Cannot re-register default hotkey.", 1);

                            sprintf(text, "\nError registering new hotkey: %s", buffer);
                        }

                        /* Save */
                        set_setting(SETTING_HOTMOD, modifiers);
                        set_setting(SETTING_HOTKEY, i);

                        /* Update window */
                        SetWindowText(hEdit, _T(text));
                        break;
                    }
                }
            }

            TranslateMessage(&msg);
            DispatchMessage(&msg);
        } 
    }
コード例 #24
0
ファイル: preferences.c プロジェクト: donovank/lxterminal
/* Initialize and display the preferences dialog. */
void terminal_preferences_dialog(GtkAction * action, LXTerminal * terminal)
{
    Setting * setting = copy_setting(get_setting());

    GtkBuilder * builder = gtk_builder_new();
    if ( ! gtk_builder_add_from_file(builder, PACKAGE_DATA_DIR "/lxterminal/lxterminal-preferences.ui", NULL))
    {
        g_object_unref(builder);
        return;
    }

    GtkDialog * dialog = GTK_DIALOG(gtk_builder_get_object(builder, "lxterminal_preferences"));
    gtk_window_set_title(GTK_WINDOW(dialog), _("LXTerminal"));
    gtk_window_set_icon_from_file(GTK_WINDOW(dialog), PACKAGE_DATA_DIR "/icons/hicolor/128x128/apps/lxterminal.png", NULL);

    GtkWidget * w = GTK_WIDGET(gtk_builder_get_object(builder, "terminal_font"));
    gtk_font_button_set_font_name(GTK_FONT_BUTTON(w), setting->font_name);
    g_signal_connect(G_OBJECT(w), "font-set", G_CALLBACK(preferences_dialog_font_set_event), setting);

    w = GTK_WIDGET(gtk_builder_get_object(builder, "background_color"));
    gtk_color_button_set_color(GTK_COLOR_BUTTON(w), &setting->background_color);
    gtk_color_button_set_alpha(GTK_COLOR_BUTTON(w), setting->background_alpha);
    g_signal_connect(G_OBJECT(w), "color-set", 
        G_CALLBACK(preferences_dialog_background_color_set_event), setting);

    w = GTK_WIDGET(gtk_builder_get_object(builder, "foreground_color"));
    gtk_color_button_set_color(GTK_COLOR_BUTTON(w), &setting->foreground_color);
    g_signal_connect(G_OBJECT(w), "color-set", 
        G_CALLBACK(preferences_dialog_foreground_color_set_event), setting);

    w = GTK_WIDGET(gtk_builder_get_object(builder, "allow_bold"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), ! setting->disallow_bold);
    g_signal_connect(G_OBJECT(w), "toggled", 
        G_CALLBACK(preferences_dialog_allow_bold_toggled_event), setting);

    w = GTK_WIDGET(gtk_builder_get_object(builder, "cursor_blink"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), setting->cursor_blink);
    g_signal_connect(G_OBJECT(w), "toggled", 
        G_CALLBACK(preferences_dialog_generic_toggled_event), &setting->cursor_blink);

    w = GTK_WIDGET(gtk_builder_get_object(builder, "cursor_style_block"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), ! setting->cursor_underline);

    w = GTK_WIDGET(gtk_builder_get_object(builder, "cursor_style_underline"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), setting->cursor_underline);
    g_signal_connect(G_OBJECT(w), "toggled", 
        G_CALLBACK(preferences_dialog_generic_toggled_event), &setting->cursor_underline);

    w = GTK_WIDGET(gtk_builder_get_object(builder, "audible_bell"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), setting->audible_bell);
    g_signal_connect(G_OBJECT(w), "toggled", 
        G_CALLBACK(preferences_dialog_generic_toggled_event), &setting->audible_bell);

    w = GTK_WIDGET(gtk_builder_get_object(builder, "tab_position"));
    gtk_combo_box_set_active(GTK_COMBO_BOX(w), terminal_tab_get_position_id(setting->tab_position));
    g_signal_connect(G_OBJECT(w), "changed", 
        G_CALLBACK(preferences_dialog_tab_position_changed_event), setting);

    w = GTK_WIDGET(gtk_builder_get_object(builder, "scrollback_lines"));
    gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), setting->scrollback);
    g_signal_connect(G_OBJECT(w), "value-changed", 
        G_CALLBACK(preferences_dialog_scrollback_value_changed_event), setting);

    w = GTK_WIDGET(gtk_builder_get_object(builder, "hide_scroll_bar"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), setting->hide_scroll_bar);
    g_signal_connect(G_OBJECT(w), "toggled", 
        G_CALLBACK(preferences_dialog_generic_toggled_event), &setting->hide_scroll_bar);

    w = GTK_WIDGET(gtk_builder_get_object(builder, "hide_menu_bar"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), setting->hide_menu_bar);
    g_signal_connect(G_OBJECT(w), "toggled", 
        G_CALLBACK(preferences_dialog_generic_toggled_event), &setting->hide_menu_bar);

    w = GTK_WIDGET(gtk_builder_get_object(builder, "hide_close_button"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), setting->hide_close_button);
    g_signal_connect(G_OBJECT(w), "toggled", 
        G_CALLBACK(preferences_dialog_generic_toggled_event), &setting->hide_close_button);

    w = GTK_WIDGET(gtk_builder_get_object(builder, "hide_pointer"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), setting->hide_pointer);
    g_signal_connect(G_OBJECT(w), "toggled", 
        G_CALLBACK(preferences_dialog_generic_toggled_event), &setting->hide_pointer);

    w = GTK_WIDGET(gtk_builder_get_object(builder, "select_by_word"));
    gtk_entry_set_text(GTK_ENTRY(w), setting->word_selection_characters);
    g_signal_connect(G_OBJECT(w), "focus-out-event", 
        G_CALLBACK(preferences_dialog_generic_focus_out_event), setting->word_selection_characters);

    w = GTK_WIDGET(gtk_builder_get_object(builder, "disable_f10"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), setting->disable_f10);
    g_signal_connect(G_OBJECT(w), "toggled", 
        G_CALLBACK(preferences_dialog_generic_toggled_event), &setting->disable_f10);

    w = GTK_WIDGET(gtk_builder_get_object(builder, "disable_alt"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), setting->disable_alt);
    g_signal_connect(G_OBJECT(w), "toggled", 
        G_CALLBACK(preferences_dialog_generic_toggled_event), &setting->disable_alt);
    
    /* Shortcuts */
    w = GTK_WIDGET(gtk_builder_get_object(builder, NEW_WINDOW_ACCEL));
    gtk_entry_set_text(GTK_ENTRY(w), setting->new_window_accel);
    g_signal_connect(G_OBJECT(w), "focus-out-event", 
        G_CALLBACK(preferences_dialog_shortcut_focus_out_event), setting->new_window_accel);

    w = GTK_WIDGET(gtk_builder_get_object(builder, NEW_TAB_ACCEL));
    gtk_entry_set_text(GTK_ENTRY(w), setting->new_tab_accel);
    g_signal_connect(G_OBJECT(w), "focus-out-event", 
        G_CALLBACK(preferences_dialog_shortcut_focus_out_event), setting->new_tab_accel);

    w = GTK_WIDGET(gtk_builder_get_object(builder, CLOSE_TAB_ACCEL));
    gtk_entry_set_text(GTK_ENTRY(w), setting->close_tab_accel);
    g_signal_connect(G_OBJECT(w), "focus-out-event", 
        G_CALLBACK(preferences_dialog_shortcut_focus_out_event), setting->close_tab_accel);

    w = GTK_WIDGET(gtk_builder_get_object(builder, CLOSE_WINDOW_ACCEL));
    gtk_entry_set_text(GTK_ENTRY(w), setting->close_window_accel);
    g_signal_connect(G_OBJECT(w), "focus-out-event", 
        G_CALLBACK(preferences_dialog_shortcut_focus_out_event), setting->close_window_accel);

    w = GTK_WIDGET(gtk_builder_get_object(builder, COPY_ACCEL));
    gtk_entry_set_text(GTK_ENTRY(w), setting->copy_accel);
    g_signal_connect(G_OBJECT(w), "focus-out-event", 
        G_CALLBACK(preferences_dialog_shortcut_focus_out_event), setting->copy_accel);

    w = GTK_WIDGET(gtk_builder_get_object(builder, PASTE_ACCEL));
    gtk_entry_set_text(GTK_ENTRY(w), setting->paste_accel);
    g_signal_connect(G_OBJECT(w), "focus-out-event", 
        G_CALLBACK(preferences_dialog_shortcut_focus_out_event), setting->paste_accel);

    w = GTK_WIDGET(gtk_builder_get_object(builder, NAME_TAB_ACCEL));
    gtk_entry_set_text(GTK_ENTRY(w), setting->name_tab_accel);
    g_signal_connect(G_OBJECT(w), "focus-out-event", 
        G_CALLBACK(preferences_dialog_shortcut_focus_out_event), setting->name_tab_accel);

    w = GTK_WIDGET(gtk_builder_get_object(builder, PREVIOUS_TAB_ACCEL));
    gtk_entry_set_text(GTK_ENTRY(w), setting->previous_tab_accel);
    g_signal_connect(G_OBJECT(w), "focus-out-event", 
        G_CALLBACK(preferences_dialog_shortcut_focus_out_event), setting->previous_tab_accel);

    w = GTK_WIDGET(gtk_builder_get_object(builder, NEXT_TAB_ACCEL));
    gtk_entry_set_text(GTK_ENTRY(w), setting->next_tab_accel);
    g_signal_connect(G_OBJECT(w), "focus-out-event", 
        G_CALLBACK(preferences_dialog_shortcut_focus_out_event), setting->next_tab_accel);

    w = GTK_WIDGET(gtk_builder_get_object(builder, MOVE_TAB_LEFT_ACCEL));
    gtk_entry_set_text(GTK_ENTRY(w), setting->move_tab_left_accel);
    g_signal_connect(G_OBJECT(w), "focus-out-event", 
        G_CALLBACK(preferences_dialog_shortcut_focus_out_event), setting->move_tab_left_accel);

    w = GTK_WIDGET(gtk_builder_get_object(builder, MOVE_TAB_RIGHT_ACCEL));
    gtk_entry_set_text(GTK_ENTRY(w), setting->move_tab_right_accel);
    g_signal_connect(G_OBJECT(w), "focus-out-event", 
        G_CALLBACK(preferences_dialog_shortcut_focus_out_event), setting->move_tab_right_accel);

    g_object_unref(builder);

    gtk_window_set_modal(GTK_WINDOW(GTK_DIALOG(dialog)), TRUE);
    gtk_window_set_transient_for(GTK_WINDOW(GTK_DIALOG(dialog)), 
        GTK_WINDOW(terminal->window));

    int result = gtk_dialog_run(dialog);
    /* Dismiss dialog. */
    gtk_widget_destroy(GTK_WIDGET(dialog));
    if (result == GTK_RESPONSE_OK)
    {
        set_setting(setting);
        save_setting();
        terminal_settings_apply_to_all(terminal);
    }
    else
    {
        free_setting(setting);
    }
}