/** * show_properties_dialog * * Description: * displays the properties dialog **/ void show_properties_dialog (void) { GtkWidget *notebook; GtkWidget *cpage; GtkWidget *gpage; GtkWidget *kpage; GtkWidget *label; GtkWidget *hbox; GtkWidget *vbox; GtkWidget *typemenu; GtkWidget *pmapmenu; GtkWidget *chkbox; GtkWidget *table; GtkWidget *dbut; GtkWidget *frame; GtkWidget *w; GtkWidget *controls_list; if (propbox) return; propbox = gtk_dialog_new_with_buttons (_("Robots Preferences"), GTK_WINDOW (app), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CLOSE, GTK_RESPONSE_ACCEPT, NULL); gtk_dialog_set_has_separator (GTK_DIALOG (propbox), FALSE); gtk_container_set_border_width (GTK_CONTAINER (propbox), 5); gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (propbox)->vbox), 2); /* Set up notebook and add it to hbox of the gtk_dialog */ g_signal_connect (G_OBJECT (propbox), "destroy", G_CALLBACK (gtk_widget_destroyed), &propbox); notebook = gtk_notebook_new (); gtk_container_set_border_width (GTK_CONTAINER (notebook), 5); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (propbox)->vbox), notebook, TRUE, TRUE, 0); /* The configuration page */ cpage = gtk_vbox_new (FALSE, 18); gtk_container_set_border_width (GTK_CONTAINER (cpage), 12); frame = games_frame_new (_("Game Type")); gtk_box_pack_start (GTK_BOX (cpage), frame, FALSE, FALSE, 0); vbox = gtk_vbox_new (FALSE, 6); gtk_container_add (GTK_CONTAINER (frame), vbox); hbox = gtk_hbox_new (TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); typemenu = gtk_combo_box_new_text (); g_signal_connect (G_OBJECT (typemenu), "changed", G_CALLBACK (type_selection), NULL); fill_typemenu (typemenu); gtk_box_pack_start (GTK_BOX (hbox), typemenu, TRUE, TRUE, 0); frame = games_frame_new (_("Options")); gtk_box_pack_start (GTK_BOX (cpage), frame, FALSE, FALSE, 0); vbox = gtk_vbox_new (TRUE, 6); gtk_container_add (GTK_CONTAINER (frame), vbox); chkbox = gtk_check_button_new_with_mnemonic (_("_Use safe moves")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkbox), properties.safe_moves); g_signal_connect (G_OBJECT (chkbox), "clicked", (GCallback) safe_cb, NULL); gtk_box_pack_start (GTK_BOX (vbox), chkbox, TRUE, TRUE, 0); gtk_widget_set_tooltip_text (chkbox, _("Prevent accidental moves that result in getting killed.")); chkbox = gtk_check_button_new_with_mnemonic (_("U_se super safe moves")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkbox), properties.super_safe_moves); g_signal_connect (G_OBJECT (chkbox), "clicked", (GCallback) super_safe_cb, NULL); gtk_box_pack_start (GTK_BOX (vbox), chkbox, TRUE, TRUE, 0); gtk_widget_set_tooltip_text (chkbox, _("Prevents all moves that result in getting killed.")); frame = games_frame_new (_("Sound")); gtk_box_pack_start (GTK_BOX (cpage), frame, FALSE, FALSE, 0); vbox = gtk_vbox_new (TRUE, 6); gtk_container_add (GTK_CONTAINER (frame), vbox); chkbox = gtk_check_button_new_with_mnemonic (_("_Enable sounds")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkbox), properties.sound); g_signal_connect (G_OBJECT (chkbox), "clicked", (GCallback) sound_cb, NULL); gtk_box_pack_start (GTK_BOX (vbox), chkbox, TRUE, TRUE, 0); gtk_widget_set_tooltip_text (chkbox, _("Play sounds for events like winning a level and dying.")); label = gtk_label_new_with_mnemonic (_("Game")); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), cpage, label); /* The graphics page */ gpage = gtk_vbox_new (FALSE, 18); gtk_container_set_border_width (GTK_CONTAINER (gpage), 12); frame = games_frame_new (_("Graphics Theme")); gtk_box_pack_start (GTK_BOX (gpage), frame, FALSE, FALSE, 0); table = gtk_table_new (2, 2, FALSE); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_table_set_col_spacings (GTK_TABLE (table), 12); gtk_container_add (GTK_CONTAINER (frame), table); label = gtk_label_new_with_mnemonic (_("_Image theme:")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); pmapmenu = make_theme_menu (); g_signal_connect (G_OBJECT (pmapmenu), "changed", G_CALLBACK (pmap_selection), NULL); gtk_label_set_mnemonic_widget (GTK_LABEL (label), pmapmenu); gtk_table_attach_defaults (GTK_TABLE (table), pmapmenu, 1, 2, 0, 1); label = gtk_label_new_with_mnemonic (_("_Background color:")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0); w = gtk_color_button_new (); gtk_color_button_set_color (GTK_COLOR_BUTTON (w), &properties.bgcolour); g_signal_connect (G_OBJECT (w), "color_set", G_CALLBACK (bg_color_callback), NULL); gtk_label_set_mnemonic_widget (GTK_LABEL (label), w); gtk_table_attach_defaults (GTK_TABLE (table), w, 1, 2, 1, 2); label = gtk_label_new_with_mnemonic (_("Appearance")); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), gpage, label); /* The keyboard page */ kpage = gtk_vbox_new (FALSE, 18); gtk_container_set_border_width (GTK_CONTAINER (kpage), 12); frame = games_frame_new (_("Keyboard Controls")); gtk_box_pack_start (GTK_BOX (kpage), frame, TRUE, TRUE, 0); vbox = gtk_vbox_new (FALSE, 6); gtk_container_add (GTK_CONTAINER (frame), vbox); controls_list = games_controls_list_new (KEY_PREFERENCES_GROUP); games_controls_list_add_controls (GAMES_CONTROLS_LIST (controls_list), "key00", _("Key to move NW"), default_keys[0], "key01", _("Key to move N"), default_keys[1], "key02", _("Key to move NE"), default_keys[2], "key03", _("Key to move W"), default_keys[3], "key05", _("Key to move E"), default_keys[5], "key06", _("Key to move SW"), default_keys[6], "key07", _("Key to move S"), default_keys[7], "key08", _("Key to move SE"), default_keys[8], "key04", _("Key to hold"), default_keys[4], "key09", _("Key to teleport"), default_keys[9], "key10", _("Key to teleport randomly"), default_keys[10], "key11", _("Key to wait"), default_keys[11], NULL); gtk_box_pack_start (GTK_BOX (vbox), controls_list, TRUE, TRUE, 0); hbox = gtk_hbutton_box_new (); gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_START); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); dbut = gtk_button_new_with_mnemonic (_("_Restore Defaults")); g_signal_connect (G_OBJECT (dbut), "clicked", G_CALLBACK (defkey_cb), (gpointer) default_keys); gtk_box_pack_start (GTK_BOX (hbox), dbut, FALSE, FALSE, 0); label = gtk_label_new_with_mnemonic (_("Keyboard")); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), kpage, label); g_signal_connect (G_OBJECT (propbox), "delete_event", G_CALLBACK (delete_cb), NULL); g_signal_connect (G_OBJECT (propbox), "response", G_CALLBACK (apply_cb), NULL); gtk_window_set_modal (GTK_WINDOW (propbox), TRUE); gtk_widget_show_all (propbox); }
/** * show_properties_dialog * * Description: * displays the properties dialog **/ void show_properties_dialog (void) { GtkWidget *notebook; GtkWidget *cpage; GtkWidget *gpage; GtkWidget *kpage; GtkWidget *label; GtkWidget *hbox; GtkWidget *vbox; GtkWidget *typemenu; GtkWidget *pmapmenu; GtkWidget *chkbox; GtkWidget *safe_chkbox; GtkWidget *grid; GtkWidget *dbut; GtkWidget *w; GtkWidget *controls_list; if (propbox) return; propbox = gtk_dialog_new_with_buttons (_("Preferences"), GTK_WINDOW (window), GTK_DIALOG_USE_HEADER_BAR, NULL); gtk_container_set_border_width (GTK_CONTAINER (propbox), 5); gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (propbox))), 2); /* Set up notebook and add it to hbox of the gtk_dialog */ g_signal_connect (G_OBJECT (propbox), "destroy", G_CALLBACK (gtk_widget_destroyed), &propbox); notebook = gtk_notebook_new (); gtk_container_set_border_width (GTK_CONTAINER (notebook), 5); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (propbox))), notebook, TRUE, TRUE, 0); /* The configuration page */ cpage = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18); gtk_container_set_border_width (GTK_CONTAINER (cpage), 12); grid = gtk_grid_new (); gtk_grid_set_row_spacing (GTK_GRID (grid), 6); gtk_grid_set_column_spacing (GTK_GRID (grid), 12); gtk_box_pack_start (GTK_BOX (cpage), grid, FALSE, FALSE, 0); label = gtk_label_new (_("Game Type")); gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1); typemenu = gtk_combo_box_text_new (); fill_typemenu (typemenu); gtk_grid_attach (GTK_GRID (grid), typemenu, 1, 0, 1, 1); g_signal_connect (G_OBJECT (typemenu), "changed", G_CALLBACK (type_selection), NULL); chkbox = gtk_check_button_new_with_mnemonic (_("_Use safe moves")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkbox), properties.safe_moves); gtk_grid_attach (GTK_GRID (grid), chkbox, 0, 1, 2, 1); gtk_widget_set_tooltip_text (chkbox, _("Prevent accidental moves that result in getting killed.")); safe_chkbox = chkbox; chkbox = gtk_check_button_new_with_mnemonic (_("U_se super safe moves")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkbox), properties.super_safe_moves); g_signal_connect (G_OBJECT (chkbox), "clicked", (GCallback) super_safe_cb, NULL); gtk_grid_attach (GTK_GRID (grid), chkbox, 0, 2, 2, 1); gtk_widget_set_tooltip_text (chkbox, _("Prevents all moves that result in getting killed.")); gtk_widget_set_sensitive (chkbox, properties.safe_moves); g_signal_connect (G_OBJECT (safe_chkbox), "clicked", (GCallback) safe_cb, (gpointer) chkbox); chkbox = gtk_check_button_new_with_mnemonic (_("_Enable sounds")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkbox), properties.sound); g_signal_connect (G_OBJECT (chkbox), "clicked", (GCallback) sound_cb, NULL); gtk_grid_attach (GTK_GRID (grid), chkbox, 0, 3, 2, 1); gtk_widget_set_tooltip_text (chkbox, _("Play sounds for events like winning a level and dying.")); label = gtk_label_new_with_mnemonic (_("Game")); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), cpage, label); /* The graphics page */ gpage = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18); gtk_container_set_border_width (GTK_CONTAINER (gpage), 12); grid = gtk_grid_new (); gtk_grid_set_row_spacing (GTK_GRID (grid), 6); gtk_grid_set_column_spacing (GTK_GRID (grid), 12); gtk_box_pack_start (GTK_BOX (gpage), grid, FALSE, FALSE, 0); label = gtk_label_new_with_mnemonic (_("_Image theme:")); gtk_widget_set_hexpand (label, TRUE); gtk_widget_set_halign (label, GTK_ALIGN_START); gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1); pmapmenu = make_theme_menu (); g_signal_connect (G_OBJECT (pmapmenu), "changed", G_CALLBACK (pmap_selection), NULL); gtk_label_set_mnemonic_widget (GTK_LABEL (label), pmapmenu); gtk_grid_attach (GTK_GRID (grid), pmapmenu, 1, 0, 1, 1); label = gtk_label_new_with_mnemonic (_("_Background color:")); gtk_widget_set_halign (label, GTK_ALIGN_START); gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1); w = gtk_color_button_new (); gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (w), &properties.bgcolour); g_signal_connect (G_OBJECT (w), "color_set", G_CALLBACK (bg_color_callback), NULL); gtk_label_set_mnemonic_widget (GTK_LABEL (label), w); gtk_grid_attach (GTK_GRID (grid), w, 1, 1, 1, 1); label = gtk_label_new_with_mnemonic (_("Appearance")); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), gpage, label); /* The keyboard page */ kpage = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18); gtk_container_set_border_width (GTK_CONTAINER (kpage), 12); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_box_pack_start (GTK_BOX (kpage), vbox, TRUE, TRUE, 0); controls_list = games_controls_list_new (settings); games_controls_list_add_controls (GAMES_CONTROLS_LIST (controls_list), "key00", _("Key to move NW"), g_settings_get_default_value (settings, "key00"), "key01", _("Key to move N"), g_settings_get_default_value (settings, "key01"), "key02", _("Key to move NE"), g_settings_get_default_value (settings, "key02"), "key03", _("Key to move W"), g_settings_get_default_value (settings, "key03"), "key04", _("Key to hold"), g_settings_get_default_value (settings, "key04"), "key05", _("Key to move E"), g_settings_get_default_value (settings, "key05"), "key06", _("Key to move SW"), g_settings_get_default_value (settings, "key06"), "key07", _("Key to move S"), g_settings_get_default_value (settings, "key07"), "key08", _("Key to move SE"), g_settings_get_default_value (settings, "key08"), NULL); gtk_box_pack_start (GTK_BOX (vbox), controls_list, TRUE, TRUE, 0); hbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_START); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); dbut = gtk_button_new_with_mnemonic (_("_Restore Defaults")); g_signal_connect (G_OBJECT (dbut), "clicked", G_CALLBACK (defkey_cb), NULL); gtk_box_pack_start (GTK_BOX (hbox), dbut, FALSE, FALSE, 0); label = gtk_label_new_with_mnemonic (_("Keyboard")); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), kpage, label); g_signal_connect (G_OBJECT (propbox), "delete_event", G_CALLBACK (delete_cb), NULL); g_signal_connect (G_OBJECT (propbox), "response", G_CALLBACK (apply_cb), NULL); gtk_widget_show_all (propbox); }