static int __devinit pm8xxx_vib_probe(struct platform_device *pdev) { const struct pm8xxx_vibrator_platform_data *pdata = pdev->dev.platform_data; struct pm8xxx_vib *vib; u8 val; int rc; if (!pdata) return -EINVAL; if (pdata->level_mV < VIB_MIN_LEVEL_mV || pdata->level_mV > VIB_MAX_LEVEL_mV) return -EINVAL; vib = kzalloc(sizeof(*vib), GFP_KERNEL); if (!vib) return -ENOMEM; vib->pdata = pdata; vib->level = pdata->level_mV / 100; vib->dev = &pdev->dev; spin_lock_init(&vib->lock); INIT_WORK(&vib->work, pm8xxx_vib_update); hrtimer_init(&vib->vib_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); vib->vib_timer.function = pm8xxx_vib_timer_func; vib->timed_dev.name = "vibrator"; vib->timed_dev.get_time = pm8xxx_vib_get_time; vib->timed_dev.enable = pm8xxx_vib_enable; __dump_vib_regs(vib, "boot_vib_default"); /* * Configure the vibrator, it operates in manual mode * for timed_output framework. */ rc = pm8xxx_vib_read_u8(vib, &val, VIB_DRV); if (rc < 0) goto err_read_vib; val &= ~VIB_DRV_EN_MANUAL_MASK; rc = pm8xxx_vib_write_u8(vib, val, VIB_DRV); if (rc < 0) goto err_read_vib; vib->reg_vib_drv = val; rc = timed_output_dev_register(&vib->timed_dev); if (rc < 0) goto err_read_vib; if(get_silent_mode() == 1) pm8xxx_vib_enable(&vib->timed_dev, 0); else pm8xxx_vib_enable(&vib->timed_dev, pdata->initial_vibrate_ms); platform_set_drvdata(pdev, vib); vib_dev = vib; return 0; err_read_vib: kfree(vib); return rc; }
static void preferences_cb(void) { GtkWidget *silent_mode_widget; GtkWidget *widget; GtkWidget *dlg_vbox; GtkWidget *theme_label; GtkWidget *theme_list; GtkWidget *layout; guint row; gint color_summary; GList *theme_elt; int i; if (preferences_dlg != NULL) { gtk_window_present(GTK_WINDOW(preferences_dlg)); return; }; /* Caption of preferences dialog */ preferences_dlg = gtk_dialog_new_with_buttons(_("" "Pioneers Preferences"), GTK_WINDOW (app_window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); gtk_dialog_set_default_response(GTK_DIALOG(preferences_dlg), GTK_RESPONSE_CLOSE); g_signal_connect(G_OBJECT(preferences_dlg), "destroy", G_CALLBACK(gtk_widget_destroyed), &preferences_dlg); g_signal_connect(G_OBJECT(preferences_dlg), "response", G_CALLBACK(gtk_widget_destroy), NULL); gtk_widget_show(preferences_dlg); dlg_vbox = GTK_DIALOG(preferences_dlg)->vbox; gtk_widget_show(dlg_vbox); layout = gtk_table_new(6, 2, FALSE); gtk_widget_show(layout); gtk_box_pack_start(GTK_BOX(dlg_vbox), layout, FALSE, TRUE, 0); gtk_container_set_border_width(GTK_CONTAINER(layout), 5); row = 0; theme_list = gtk_combo_box_new_text(); /* Label for changing the theme, in the preferences dialog */ theme_label = gtk_label_new(_("Theme:")); gtk_misc_set_alignment(GTK_MISC(theme_label), 0, 0.5); gtk_widget_show(theme_list); gtk_widget_show(theme_label); for (i = 0, theme_elt = theme_get_list(); theme_elt != NULL; ++i, theme_elt = g_list_next(theme_elt)) { MapTheme *theme = theme_elt->data; gtk_combo_box_append_text(GTK_COMBO_BOX(theme_list), theme->name); if (theme == theme_get_current()) gtk_combo_box_set_active(GTK_COMBO_BOX(theme_list), i); } g_signal_connect(G_OBJECT(theme_list), "changed", G_CALLBACK(theme_change_cb), NULL); gtk_table_attach_defaults(GTK_TABLE(layout), theme_label, 0, 1, row, row + 1); gtk_table_attach_defaults(GTK_TABLE(layout), theme_list, 1, 2, row, row + 1); gtk_widget_set_tooltip_text(theme_list, /* Tooltip for changing the theme in the preferences dialog */ _("Choose one of the themes")); row++; /* Label for the option to show the legend */ widget = gtk_check_button_new_with_label(_("Show legend")); gtk_widget_show(widget); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), legend_page_enabled); g_signal_connect(G_OBJECT(widget), "toggled", G_CALLBACK(show_legend_cb), NULL); gtk_table_attach_defaults(GTK_TABLE(layout), widget, 0, 2, row, row + 1); gtk_widget_set_tooltip_text(widget, /* Tooltip for the option to show the legend */ _("" "Show the legend as a page beside the map")); row++; /* Label for the option to display log messages in color */ widget = gtk_check_button_new_with_label(_("Messages with color")); gtk_widget_show(widget); gtk_table_attach_defaults(GTK_TABLE(layout), widget, 0, 2, row, row + 1); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), color_messages_enabled); g_signal_connect(G_OBJECT(widget), "toggled", G_CALLBACK(message_color_cb), NULL); gtk_widget_set_tooltip_text(widget, /* Tooltip for the option to display log messages in color */ _("Show new messages with color")); row++; widget = gtk_check_button_new_with_label( /* Label for the option to display chat in color of player */ _("" "Chat in color of player")); gtk_widget_show(widget); gtk_table_attach_defaults(GTK_TABLE(layout), widget, 0, 2, row, row + 1); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), color_chat_enabled); g_signal_connect(G_OBJECT(widget), "toggled", G_CALLBACK(chat_color_cb), NULL); gtk_widget_set_tooltip_text(widget, /* Tooltip for the option to display chat in color of player */ _("" "Show new chat messages in the color of the player")); row++; /* Label for the option to display the summary with colors */ widget = gtk_check_button_new_with_label(_("Summary with color")); gtk_widget_show(widget); gtk_table_attach_defaults(GTK_TABLE(layout), widget, 0, 2, row, row + 1); color_summary = config_get_int_with_default("settings/color_summary", TRUE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), color_summary); /* @todo RC use correct variable */ g_signal_connect(G_OBJECT(widget), "toggled", G_CALLBACK(summary_color_cb), NULL); gtk_widget_set_tooltip_text(widget, /* Tooltip for the option to display the summary with colors */ _("Use colors in the player summary")); row++; widget = /* Label for the option to display keyboard accelerators in the toolbar */ gtk_check_button_new_with_label(_("Toolbar with shortcuts")); gtk_widget_show(widget); gtk_table_attach_defaults(GTK_TABLE(layout), widget, 0, 2, row, row + 1); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), toolbar_show_accelerators); g_signal_connect(G_OBJECT(widget), "toggled", G_CALLBACK(toolbar_shortcuts_cb), NULL); gtk_widget_set_tooltip_text(widget, /* Tooltip for the option to display keyboard accelerators in the toolbar */ _("" "Show keyboard shortcuts in the toolbar")); row++; silent_mode_widget = /* Label for the option to disable all sounds */ gtk_check_button_new_with_label(_("Silent mode")); gtk_widget_show(silent_mode_widget); gtk_table_attach_defaults(GTK_TABLE(layout), silent_mode_widget, 0, 2, row, row + 1); gtk_widget_set_tooltip_text(silent_mode_widget, /* Tooltip for the option to disable all sounds */ _("" "In silent mode no sounds are made")); row++; widget = /* Label for the option to announce when players/viewers enter */ gtk_check_button_new_with_label(_("Announce new players")); gtk_widget_show(widget); gtk_table_attach_defaults(GTK_TABLE(layout), widget, 0, 2, row, row + 1); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), get_announce_player()); g_signal_connect(G_OBJECT(widget), "toggled", G_CALLBACK(announce_player_cb), NULL); gtk_widget_set_tooltip_text(widget, /* Tooltip for the option to use sound when players/viewers enter */ _("" "Make a sound when a new player or viewer enters the game")); row++; /* Silent mode widget is connected an initialized after the announce button */ g_signal_connect(G_OBJECT(silent_mode_widget), "toggled", G_CALLBACK(silent_mode_cb), widget); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(silent_mode_widget), get_silent_mode()); /* Label for the option to use the 16:9 layout. */ widget = gtk_check_button_new_with_label(_("Use 16:9 layout")); gtk_widget_show(widget); gtk_table_attach_defaults(GTK_TABLE(layout), widget, 0, 2, row, row + 1); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), get_16_9_layout()); g_signal_connect(G_OBJECT(widget), "toggled", G_CALLBACK(toggle_16_9_cb), NULL); gtk_widget_set_tooltip_text(widget, /* Tooltip for 16:9 option. */ _("" "Use a 16:9 friendly layout for the window")); row++; }