void restore_defaults() { gtk_range_set_value(GTK_RANGE(seq_slide), 30); gtk_range_set_value(GTK_RANGE(seek_slide), 20); gtk_range_set_value(GTK_RANGE(over_slide), 10); }
GtkWidget *a_uibuilder_new_widget ( VikLayerParam *param, VikLayerParamData data ) { // Perform pre conversion if necessary VikLayerParamData vlpd = data; if ( param->convert_to_display ) vlpd = param->convert_to_display ( data ); GtkWidget *rv = NULL; switch ( param->widget_type ) { case VIK_LAYER_WIDGET_COLOR: if ( param->type == VIK_LAYER_PARAM_COLOR ) rv = gtk_color_button_new_with_color ( &(vlpd.c) ); break; case VIK_LAYER_WIDGET_CHECKBUTTON: if ( param->type == VIK_LAYER_PARAM_BOOLEAN ) { //rv = gtk_check_button_new_with_label ( //param->title ); rv = gtk_check_button_new (); if ( vlpd.b ) gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(rv), TRUE ); } break; case VIK_LAYER_WIDGET_COMBOBOX: if ( param->type == VIK_LAYER_PARAM_UINT && param->widget_data ) { /* Build a simple combobox */ gchar **pstr = param->widget_data; rv = vik_combo_box_text_new (); while ( *pstr ) vik_combo_box_text_append ( rv, *(pstr++) ); if ( param->extra_widget_data ) /* map of alternate uint values for options */ { /* Set the effective default value */ int i; for ( i = 0; ((const char **)param->widget_data)[i]; i++ ) if ( ((guint *)param->extra_widget_data)[i] == vlpd.u ) { /* Match default value */ gtk_combo_box_set_active ( GTK_COMBO_BOX(rv), i ); break; } } else gtk_combo_box_set_active ( GTK_COMBO_BOX ( rv ), vlpd.u ); } else if ( param->type == VIK_LAYER_PARAM_STRING && param->widget_data && !param->extra_widget_data ) { /* Build a combobox with editable text */ gchar **pstr = param->widget_data; #if GTK_CHECK_VERSION (2, 24, 0) rv = gtk_combo_box_text_new_with_entry (); #else rv = gtk_combo_box_entry_new_text (); #endif if ( vlpd.s ) vik_combo_box_text_append ( rv, vlpd.s ); while ( *pstr ) vik_combo_box_text_append ( rv, *(pstr++) ); if ( vlpd.s ) gtk_combo_box_set_active ( GTK_COMBO_BOX ( rv ), 0 ); } else if ( param->type == VIK_LAYER_PARAM_STRING && param->widget_data && param->extra_widget_data) { /* Build a combobox with fixed selections without editable text */ gchar **pstr = param->widget_data; rv = GTK_WIDGET ( vik_combo_box_text_new () ); while ( *pstr ) vik_combo_box_text_append ( rv, *(pstr++) ); if ( vlpd.s ) { /* Set the effective default value */ /* In case of value does not exist, set the first value */ gtk_combo_box_set_active ( GTK_COMBO_BOX ( rv ), 0 ); int i; for ( i = 0; ((const char **)param->widget_data)[i]; i++ ) if ( strcmp(((const char **)param->extra_widget_data)[i], vlpd.s) == 0 ) { /* Match default value */ gtk_combo_box_set_active ( GTK_COMBO_BOX ( rv ), i ); break; } } else gtk_combo_box_set_active ( GTK_COMBO_BOX ( rv ), 0 ); } break; case VIK_LAYER_WIDGET_RADIOGROUP: /* widget_data and extra_widget_data are GList */ if ( param->type == VIK_LAYER_PARAM_UINT && param->widget_data ) { rv = vik_radio_group_new ( param->widget_data ); if ( param->extra_widget_data ) /* map of alternate uint values for options */ { int i; int nb_elem = g_list_length(param->widget_data); for ( i = 0; i < nb_elem; i++ ) if ( GPOINTER_TO_UINT ( g_list_nth_data(param->extra_widget_data, i) ) == vlpd.u ) { vik_radio_group_set_selected ( VIK_RADIO_GROUP(rv), i ); break; } } else if ( vlpd.u ) /* zero is already default */ vik_radio_group_set_selected ( VIK_RADIO_GROUP(rv), vlpd.u ); } break; case VIK_LAYER_WIDGET_RADIOGROUP_STATIC: if ( param->type == VIK_LAYER_PARAM_UINT && param->widget_data ) { rv = vik_radio_group_new_static ( (const gchar **) param->widget_data ); if ( param->extra_widget_data ) /* map of alternate uint values for options */ { int i; for ( i = 0; ((const char **)param->widget_data)[i]; i++ ) if ( ((guint *)param->extra_widget_data)[i] == vlpd.u ) { vik_radio_group_set_selected ( VIK_RADIO_GROUP(rv), i ); break; } } else if ( vlpd.u ) /* zero is already default */ vik_radio_group_set_selected ( VIK_RADIO_GROUP(rv), vlpd.u ); } break; case VIK_LAYER_WIDGET_SPINBUTTON: if ( (param->type == VIK_LAYER_PARAM_DOUBLE || param->type == VIK_LAYER_PARAM_UINT || param->type == VIK_LAYER_PARAM_INT) && param->widget_data ) { gdouble init_val = (param->type == VIK_LAYER_PARAM_DOUBLE) ? vlpd.d : (param->type == VIK_LAYER_PARAM_UINT ? vlpd.u : vlpd.i); VikLayerParamScale *scale = (VikLayerParamScale *) param->widget_data; rv = gtk_spin_button_new ( GTK_ADJUSTMENT(gtk_adjustment_new( init_val, scale->min, scale->max, scale->step, scale->step, 0 )), scale->step, scale->digits ); } break; case VIK_LAYER_WIDGET_ENTRY: if ( param->type == VIK_LAYER_PARAM_STRING ) { rv = gtk_entry_new (); if ( vlpd.s ) gtk_entry_set_text ( GTK_ENTRY(rv), vlpd.s ); } break; case VIK_LAYER_WIDGET_PASSWORD: if ( param->type == VIK_LAYER_PARAM_STRING ) { rv = gtk_entry_new (); gtk_entry_set_visibility ( GTK_ENTRY(rv), FALSE ); if ( vlpd.s ) gtk_entry_set_text ( GTK_ENTRY(rv), vlpd.s ); gtk_widget_set_tooltip_text ( GTK_WIDGET(rv), _("Take care that this password will be stored clearly in a plain file.") ); } break; case VIK_LAYER_WIDGET_FILEENTRY: if ( param->type == VIK_LAYER_PARAM_STRING ) { rv = vik_file_entry_new (GTK_FILE_CHOOSER_ACTION_OPEN); if ( vlpd.s ) vik_file_entry_set_filename ( VIK_FILE_ENTRY(rv), vlpd.s ); } break; case VIK_LAYER_WIDGET_FOLDERENTRY: if ( param->type == VIK_LAYER_PARAM_STRING ) { rv = vik_file_entry_new (GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); if ( vlpd.s ) vik_file_entry_set_filename ( VIK_FILE_ENTRY(rv), vlpd.s ); } break; case VIK_LAYER_WIDGET_FILELIST: if ( param->type == VIK_LAYER_PARAM_STRING_LIST ) { rv = vik_file_list_new ( _(param->title) ); vik_file_list_set_files ( VIK_FILE_LIST(rv), vlpd.sl ); } break; case VIK_LAYER_WIDGET_HSCALE: if ( (param->type == VIK_LAYER_PARAM_DOUBLE || param->type == VIK_LAYER_PARAM_UINT || param->type == VIK_LAYER_PARAM_INT) && param->widget_data ) { gdouble init_val = (param->type == VIK_LAYER_PARAM_DOUBLE) ? vlpd.d : (param->type == VIK_LAYER_PARAM_UINT ? vlpd.u : vlpd.i); VikLayerParamScale *scale = (VikLayerParamScale *) param->widget_data; rv = gtk_hscale_new_with_range ( scale->min, scale->max, scale->step ); gtk_scale_set_digits ( GTK_SCALE(rv), scale->digits ); gtk_range_set_value ( GTK_RANGE(rv), init_val ); } } if ( rv && !gtk_widget_get_tooltip_text ( rv ) ) { if ( param->tooltip ) gtk_widget_set_tooltip_text ( rv, _(param->tooltip) ); } return rv; }
static gboolean scroll_callback_cb( void *d) { flow_sScroll *data = &((FlowWidgetGtk *)d)->scroll_data; flowwidget_sScroll *scroll_data = (flowwidget_sScroll *) data->scroll_data; ((FlowWidgetGtk *)scroll_data->flow)->scroll_timerid = 0; if ( data->total_width <= data->window_width) { if ( data->offset_x == 0) data->total_width = data->window_width; if ( scroll_data->scroll_h_managed) { // Remove horizontal scrollbar } } else { if ( !scroll_data->scroll_h_managed) { // Insert horizontal scrollbar } } if ( data->total_height <= data->window_height) { if ( data->offset_y == 0) data->total_height = data->window_height; if ( scroll_data->scroll_v_managed) { // Remove vertical scrollbar } } else { if ( !scroll_data->scroll_v_managed) { // Insert vertical scrollbar } } if ( data->offset_x < 0) { data->total_width += -data->offset_x; data->offset_x = 0; } if ( data->offset_y < 0) { data->total_height += -data->offset_y; data->offset_y = 0; } if ( data->total_height < data->window_height + data->offset_y) data->total_height = data->window_height + data->offset_y; if ( data->total_width < data->window_width + data->offset_x) data->total_width = data->window_width + data->offset_x; if ( data->window_width < 1) data->window_width = 1; if ( data->window_height < 1) data->window_height = 1; if ( scroll_data->scroll_h_managed) { ((FlowWidgetGtk *)scroll_data->flow)->scroll_h_ignore = 1; if ( data->window_width != ((FlowWidgetGtk *)scroll_data->flow)->scroll_h_pagesize || data->total_width != ((FlowWidgetGtk *)scroll_data->flow)->scroll_h_upper || ((FlowWidgetGtk *)scroll_data->flow)->scroll_configure) { g_object_set( ((GtkScrollbar *)scroll_data->scroll_h)->range.adjustment, "upper", (gdouble)data->total_width, "page-size", (gdouble)data->window_width, "value", (gdouble)data->offset_x, NULL); gtk_adjustment_changed( ((GtkScrollbar *)scroll_data->scroll_h)->range.adjustment); } else { gtk_range_set_value( GTK_RANGE(scroll_data->scroll_h), (gdouble)data->offset_x); } ((FlowWidgetGtk *)scroll_data->flow)->scroll_h_value = (gdouble)data->offset_x; ((FlowWidgetGtk *)scroll_data->flow)->scroll_h_pagesize = data->window_width; ((FlowWidgetGtk *)scroll_data->flow)->scroll_h_upper = data->total_width; } if ( scroll_data->scroll_v_managed) { ((FlowWidgetGtk *)scroll_data->flow)->scroll_v_ignore = 1; if ( data->window_height != ((FlowWidgetGtk *)scroll_data->flow)->scroll_v_pagesize || data->total_height != ((FlowWidgetGtk *)scroll_data->flow)->scroll_v_upper || ((FlowWidgetGtk *)scroll_data->flow)->scroll_configure) { g_object_set( ((GtkScrollbar *)scroll_data->scroll_v)->range.adjustment, "upper", (gdouble)data->total_height, "page-size", (gdouble)data->window_height, "value", (gdouble)data->offset_y, NULL); gtk_adjustment_changed( ((GtkScrollbar *)scroll_data->scroll_v)->range.adjustment); } else { g_object_set( ((GtkScrollbar *)scroll_data->scroll_v)->range.adjustment, "value", (gdouble)data->offset_y, NULL); gtk_adjustment_value_changed( ((GtkScrollbar *)scroll_data->scroll_v)->range.adjustment); } ((FlowWidgetGtk *)scroll_data->flow)->scroll_v_value = (gdouble)data->offset_y; ((FlowWidgetGtk *)scroll_data->flow)->scroll_h_pagesize = data->window_width; ((FlowWidgetGtk *)scroll_data->flow)->scroll_h_upper = data->total_width; } ((FlowWidgetGtk *)scroll_data->flow)->scroll_configure = 0; return FALSE; }
static int icvCreateTrackbar( const char* trackbar_name, const char* window_name, int* val, int count, CvTrackbarCallback on_notify, CvTrackbarCallback2 on_notify2, void* userdata ) { int result = 0; CV_FUNCNAME( "icvCreateTrackbar" ); __BEGIN__; /*char slider_name[32];*/ CvWindow* window = 0; CvTrackbar* trackbar = 0; if( !window_name || !trackbar_name ) CV_ERROR( CV_StsNullPtr, "NULL window or trackbar name" ); if( count <= 0 ) CV_ERROR( CV_StsOutOfRange, "Bad trackbar maximal value" ); window = icvFindWindowByName(window_name); if( !window ) EXIT; trackbar = icvFindTrackbarByName(window,trackbar_name); CV_LOCK_MUTEX(); if( !trackbar ) { int len = strlen(trackbar_name); trackbar = (CvTrackbar*)cvAlloc(sizeof(CvTrackbar) + len + 1); memset( trackbar, 0, sizeof(*trackbar)); trackbar->signature = CV_TRACKBAR_MAGIC_VAL; trackbar->name = (char*)(trackbar+1); memcpy( trackbar->name, trackbar_name, len + 1 ); trackbar->parent = window; trackbar->next = window->toolbar.first; window->toolbar.first = trackbar; GtkWidget* hscale_box = gtk_hbox_new( FALSE, 10 ); GtkWidget* hscale_label = gtk_label_new( trackbar_name ); GtkWidget* hscale = gtk_hscale_new_with_range( 0, count, 1 ); gtk_range_set_update_policy( GTK_RANGE(hscale), GTK_UPDATE_CONTINUOUS ); gtk_scale_set_digits( GTK_SCALE(hscale), 0 ); //gtk_scale_set_value_pos( hscale, GTK_POS_TOP ); gtk_scale_set_draw_value( GTK_SCALE(hscale), TRUE ); trackbar->widget = hscale; gtk_box_pack_start( GTK_BOX(hscale_box), hscale_label, FALSE, FALSE, 5 ); gtk_widget_show( hscale_label ); gtk_box_pack_start( GTK_BOX(hscale_box), hscale, TRUE, TRUE, 5 ); gtk_widget_show( hscale ); gtk_box_pack_start( GTK_BOX(window->paned), hscale_box, FALSE, FALSE, 5 ); gtk_widget_show( hscale_box ); } if( val ) { int value = *val; if( value < 0 ) value = 0; if( value > count ) value = count; gtk_range_set_value( GTK_RANGE(trackbar->widget), value ); trackbar->pos = value; trackbar->data = val; } trackbar->maxval = count; trackbar->notify = on_notify; trackbar->notify2 = on_notify2; trackbar->userdata = userdata; gtk_signal_connect( GTK_OBJECT(trackbar->widget), "value-changed", GTK_SIGNAL_FUNC(icvOnTrackbar), trackbar ); // queue a widget resize to trigger a window resize to // compensate for the addition of trackbars gtk_widget_queue_resize( GTK_WIDGET(window->widget) ); CV_UNLOCK_MUTEX(); result = 1; __END__; return result; }
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); }
static void set_slider (gint time) { gtk_range_set_value ((GtkRange *) slider, time); }
static VALUE rg_set_value(VALUE self, VALUE value) { gtk_range_set_value(_SELF(self), NUM2DBL(value)); return self; }
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); }
int main(int argc, char *argv[]) { struct stat buf = { 0 }; struct mntent *mnt = NULL; FILE *fp = NULL; gchar *uri; gint fileindex = 1; GError *error = NULL; GOptionContext *context; gint i; gdouble volume = 100.0; gchar *accelerator_keys; gchar **parse; #ifdef GTK3_ENABLED GtkSettings *gtk_settings; #endif int stat_result; #ifndef OS_WIN32 struct sigaction sa; #endif gboolean playiter = FALSE; #ifdef GIO_ENABLED GFile *file; #endif #ifdef ENABLE_NLS bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); #endif playlist = 0; embed_window = 0; control_id = 0; window_x = 0; window_y = 0; last_window_width = 0; last_window_height = 0; showcontrols = 1; showsubtitles = TRUE; autostart = 1; videopresent = 0; disable_context_menu = FALSE; dontplaynext = FALSE; idledata = (IdleData *) g_new0(IdleData, 1); idledata->videopresent = FALSE; idledata->length = 0.0; idledata->device = NULL; idledata->cachepercent = -1.0; selection = NULL; path = NULL; js_state = STATE_UNDEFINED; control_instance = TRUE; playlistname = NULL; rpconsole = NULL; subtitle = NULL; tv_device = NULL; tv_driver = NULL; tv_width = 0; tv_height = 0; tv_fps = 0; ok_to_play = TRUE; alang = NULL; slang = NULL; metadata_codepage = NULL; playlistname = NULL; window_width = -1; window_height = -1; stored_window_width = -1; stored_window_height = -1; cache_size = 0; forcecache = FALSE; use_volume_option = FALSE; vertical_layout = FALSE; playlist_visible = FALSE; disable_fullscreen = FALSE; disable_framedrop = FALSE; softvol = FALSE; remember_softvol = FALSE; volume_softvol = -1; volume_gain = 0; subtitlefont = NULL; subtitle_codepage = NULL; subtitle_color = NULL; subtitle_outline = FALSE; subtitle_shadow = FALSE; subtitle_fuzziness = 0; disable_embeddedfonts = FALSE; quit_on_complete = FALSE; verbose = 0; reallyverbose = 0; embedding_disabled = FALSE; disable_pause_on_click = FALSE; disable_animation = FALSE; auto_hide_timeout = 3; mouse_over_controls = FALSE; use_mediakeys = TRUE; use_defaultpl = FALSE; mplayer_bin = NULL; mplayer_dvd_device = NULL; single_instance = FALSE; disable_deinterlace = TRUE; details_visible = FALSE; replace_and_play = FALSE; bring_to_front = FALSE; keep_on_top = FALSE; resize_on_new_media = FALSE; use_pausing_keep_force = FALSE; show_notification = TRUE; show_status_icon = TRUE; lang_group = NULL; audio_group = NULL; gpod_mount_point = NULL; load_tracks_from_gpod = FALSE; disable_cover_art_fetch = FALSE; fullscreen = 0; vo = NULL; data = NULL; max_data = NULL; details_table = NULL; large_buttons = FALSE; button_size = GTK_ICON_SIZE_BUTTON; lastguistate = -1; non_fs_height = 0; non_fs_width = 0; use_hw_audio = FALSE; start_second = 0; play_length = 0; save_loc = TRUE; use_xscrnsaver = FALSE; screensaver_disabled = FALSE; update_control_flag = FALSE; gchar *filename; skip_fixed_allocation_on_show = FALSE; skip_fixed_allocation_on_hide = FALSE; pref_volume = -1; use_mplayer2 = FALSE; enable_global_menu = FALSE; #ifndef OS_WIN32 sa.sa_handler = hup_handler; sigemptyset(&sa.sa_mask); #ifdef SA_RESTART sa.sa_flags = SA_RESTART; /* Restart functions if interrupted by handler */ #endif #ifdef SIGINT if (sigaction(SIGINT, &sa, NULL) == -1) printf("SIGINT signal handler not installed\n"); #endif #ifdef SIGHUP if (sigaction(SIGHUP, &sa, NULL) == -1) printf("SIGHUP signal handler not installed\n"); #endif #ifdef SIGTERM if (sigaction(SIGTERM, &sa, NULL) == -1) printf("SIGTERM signal handler not installed\n"); #endif #endif // call g_type_init or otherwise we can crash gtk_init(&argc, &argv); if (!g_thread_supported()) g_thread_init(NULL); uri = g_strdup_printf("%s/gnome-mplayer/cover_art", g_get_user_config_dir()); if (!g_file_test(uri, G_FILE_TEST_IS_DIR)) { g_mkdir_with_parents(uri, 0775); } g_free(uri); uri = g_strdup_printf("%s/gnome-mplayer/plugin", g_get_user_config_dir()); if (!g_file_test(uri, G_FILE_TEST_IS_DIR)) { g_mkdir_with_parents(uri, 0775); } g_free(uri); uri = NULL; default_playlist = g_strdup_printf("file://%s/gnome-mplayer/default.pls", g_get_user_config_dir()); safe_to_save_default_playlist = TRUE; gm_store = gm_pref_store_new("gnome-mplayer"); gmp_store = gm_pref_store_new("gecko-mediaplayer"); vo = gm_pref_store_get_string(gm_store, VO); audio_device.alsa_mixer = gm_pref_store_get_string(gm_store, ALSA_MIXER); use_hardware_codecs = gm_pref_store_get_boolean(gm_store, USE_HARDWARE_CODECS); use_crystalhd_codecs = gm_pref_store_get_boolean(gm_store, USE_CRYSTALHD_CODECS); osdlevel = gm_pref_store_get_int(gm_store, OSDLEVEL); pplevel = gm_pref_store_get_int(gm_store, PPLEVEL); #ifndef HAVE_ASOUNDLIB volume = gm_pref_store_get_int(gm_store, VOLUME); #endif audio_channels = gm_pref_store_get_int(gm_store, AUDIO_CHANNELS); use_hw_audio = gm_pref_store_get_boolean(gm_store, USE_HW_AUDIO); fullscreen = gm_pref_store_get_boolean(gm_store, FULLSCREEN); softvol = gm_pref_store_get_boolean(gm_store, SOFTVOL); remember_softvol = gm_pref_store_get_boolean(gm_store, REMEMBER_SOFTVOL); volume_softvol = gm_pref_store_get_float(gm_store, VOLUME_SOFTVOL); volume_gain = gm_pref_store_get_int(gm_store, VOLUME_GAIN); forcecache = gm_pref_store_get_boolean(gm_store, FORCECACHE); vertical_layout = gm_pref_store_get_boolean(gm_store, VERTICAL); playlist_visible = gm_pref_store_get_boolean(gm_store, SHOWPLAYLIST); details_visible = gm_pref_store_get_boolean(gm_store, SHOWDETAILS); show_notification = gm_pref_store_get_boolean(gm_store, SHOW_NOTIFICATION); show_status_icon = gm_pref_store_get_boolean(gm_store, SHOW_STATUS_ICON); showcontrols = gm_pref_store_get_boolean_with_default(gm_store, SHOW_CONTROLS, showcontrols); restore_controls = showcontrols; disable_deinterlace = gm_pref_store_get_boolean(gm_store, DISABLEDEINTERLACE); disable_framedrop = gm_pref_store_get_boolean(gm_store, DISABLEFRAMEDROP); disable_fullscreen = gm_pref_store_get_boolean(gm_store, DISABLEFULLSCREEN); disable_context_menu = gm_pref_store_get_boolean(gm_store, DISABLECONTEXTMENU); disable_ass = gm_pref_store_get_boolean(gm_store, DISABLEASS); disable_embeddedfonts = gm_pref_store_get_boolean(gm_store, DISABLEEMBEDDEDFONTS); disable_pause_on_click = gm_pref_store_get_boolean(gm_store, DISABLEPAUSEONCLICK); disable_animation = gm_pref_store_get_boolean(gm_store, DISABLEANIMATION); auto_hide_timeout = gm_pref_store_get_int_with_default(gm_store, AUTOHIDETIMEOUT, auto_hide_timeout); disable_cover_art_fetch = gm_pref_store_get_boolean(gm_store, DISABLE_COVER_ART_FETCH); use_mediakeys = gm_pref_store_get_boolean_with_default(gm_store, USE_MEDIAKEYS, use_mediakeys); use_defaultpl = gm_pref_store_get_boolean_with_default(gm_store, USE_DEFAULTPL, use_defaultpl); metadata_codepage = gm_pref_store_get_string(gm_store, METADATACODEPAGE); alang = gm_pref_store_get_string(gm_store, AUDIO_LANG); slang = gm_pref_store_get_string(gm_store, SUBTITLE_LANG); subtitlefont = gm_pref_store_get_string(gm_store, SUBTITLEFONT); subtitle_scale = gm_pref_store_get_float(gm_store, SUBTITLESCALE); if (subtitle_scale < 0.25) { subtitle_scale = 1.0; } subtitle_codepage = gm_pref_store_get_string(gm_store, SUBTITLECODEPAGE); subtitle_color = gm_pref_store_get_string(gm_store, SUBTITLECOLOR); subtitle_outline = gm_pref_store_get_boolean(gm_store, SUBTITLEOUTLINE); subtitle_shadow = gm_pref_store_get_boolean(gm_store, SUBTITLESHADOW); subtitle_margin = gm_pref_store_get_int(gm_store, SUBTITLE_MARGIN); subtitle_fuzziness = gm_pref_store_get_int(gm_store, SUBTITLE_FUZZINESS); showsubtitles = gm_pref_store_get_boolean_with_default(gm_store, SHOW_SUBTITLES, TRUE); qt_disabled = gm_pref_store_get_boolean(gmp_store, DISABLE_QT); real_disabled = gm_pref_store_get_boolean(gmp_store, DISABLE_REAL); wmp_disabled = gm_pref_store_get_boolean(gmp_store, DISABLE_WMP); dvx_disabled = gm_pref_store_get_boolean(gmp_store, DISABLE_DVX); midi_disabled = gm_pref_store_get_boolean(gmp_store, DISABLE_MIDI); embedding_disabled = gm_pref_store_get_boolean(gmp_store, DISABLE_EMBEDDING); disable_embedded_scaling = gm_pref_store_get_boolean(gmp_store, DISABLE_EMBEDDED_SCALING); if (embed_window == 0) { single_instance = gm_pref_store_get_boolean(gm_store, SINGLE_INSTANCE); if (single_instance) { replace_and_play = gm_pref_store_get_boolean(gm_store, REPLACE_AND_PLAY); bring_to_front = gm_pref_store_get_boolean(gm_store, BRING_TO_FRONT); } } enable_global_menu = gm_pref_store_get_boolean(gm_store, ENABLE_GLOBAL_MENU); if (!enable_global_menu) { enable_global_menu = (g_getenv("UBUNTU_MENUPROXY") == NULL ? FALSE : TRUE); } enable_nautilus_plugin = gm_pref_store_get_boolean_with_default(gm_store, ENABLE_NAUTILUS_PLUGIN, TRUE); mplayer_bin = gm_pref_store_get_string(gm_store, MPLAYER_BIN); if (mplayer_bin != NULL && !g_file_test(mplayer_bin, G_FILE_TEST_EXISTS)) { g_free(mplayer_bin); mplayer_bin = NULL; } mplayer_dvd_device = gm_pref_store_get_string(gm_store, MPLAYER_DVD_DEVICE); extraopts = gm_pref_store_get_string(gm_store, EXTRAOPTS); use_xscrnsaver = gm_pref_store_get_boolean_with_default(gm_store, USE_XSCRNSAVER, use_xscrnsaver); accelerator_keys = gm_pref_store_get_string(gm_store, ACCELERATOR_KEYS); accel_keys = g_strv_new(KEY_COUNT); accel_keys_description = g_strv_new(KEY_COUNT); if (accelerator_keys != NULL) { parse = g_strsplit(accelerator_keys, " ", KEY_COUNT); for (i = 0; i < g_strv_length(parse); i++) { accel_keys[i] = g_strdup(parse[i]); } g_free(accelerator_keys); g_strfreev(parse); } assign_default_keys(); accel_keys_description[FILE_OPEN_LOCATION] = g_strdup(_("Open Location")); accel_keys_description[EDIT_SCREENSHOT] = g_strdup(_("Take Screenshot")); accel_keys_description[EDIT_PREFERENCES] = g_strdup(_("Preferences")); accel_keys_description[VIEW_PLAYLIST] = g_strdup(_("Playlist")); accel_keys_description[VIEW_INFO] = g_strdup(_("Media Info")); accel_keys_description[VIEW_DETAILS] = g_strdup(_("Details")); accel_keys_description[VIEW_METER] = g_strdup(_("Audio Meter")); accel_keys_description[VIEW_FULLSCREEN] = g_strdup(_("Full Screen")); accel_keys_description[VIEW_ASPECT] = g_strdup(_("Aspect")); accel_keys_description[VIEW_SUBTITLES] = g_strdup(_("Subtitles")); accel_keys_description[VIEW_DECREASE_SIZE] = g_strdup(_("Decrease Subtitle Size")); accel_keys_description[VIEW_INCREASE_SIZE] = g_strdup(_("Increase Subtitle Size")); accel_keys_description[VIEW_ANGLE] = g_strdup(_("Switch Angle")); accel_keys_description[VIEW_CONTROLS] = g_strdup(_("Controls")); remember_loc = gm_pref_store_get_boolean(gm_store, REMEMBER_LOC); loc_window_x = gm_pref_store_get_int(gm_store, WINDOW_X); loc_window_y = gm_pref_store_get_int(gm_store, WINDOW_Y); loc_window_height = gm_pref_store_get_int(gm_store, WINDOW_HEIGHT); loc_window_width = gm_pref_store_get_int(gm_store, WINDOW_WIDTH); loc_panel_position = gm_pref_store_get_int(gm_store, PANEL_POSITION); keep_on_top = gm_pref_store_get_boolean(gm_store, KEEP_ON_TOP); resize_on_new_media = gm_pref_store_get_boolean(gm_store, RESIZE_ON_NEW_MEDIA); mouse_wheel_changes_volume = gm_pref_store_get_boolean_with_default(gm_store, MOUSE_WHEEL_CHANGES_VOLUME, FALSE); audio_device_name = gm_pref_store_get_string(gm_store, AUDIO_DEVICE_NAME); audio_device.description = g_strdup(audio_device_name); context = g_option_context_new(_("[FILES...] - GNOME Media player based on MPlayer")); #ifdef GTK2_12_ENABLED g_option_context_set_translation_domain(context, "UTF-8"); g_option_context_set_translate_func(context, (GTranslateFunc) gettext, NULL, NULL); #endif g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE); g_option_context_add_group(context, gtk_get_option_group(TRUE)); g_option_context_parse(context, &argc, &argv, &error); g_option_context_free(context); if (new_instance) single_instance = FALSE; if (verbose == 0) verbose = gm_pref_store_get_int(gm_store, VERBOSE); if (reallyverbose) verbose = 2; if (verbose) { printf(_("GNOME MPlayer v%s\n"), VERSION); printf(_("gmtk v%s\n"), gmtk_version()); } if (cache_size == 0) cache_size = gm_pref_store_get_int(gm_store, CACHE_SIZE); if (cache_size == 0) cache_size = 2000; plugin_audio_cache_size = gm_pref_store_get_int(gm_store, PLUGIN_AUDIO_CACHE_SIZE); if (plugin_audio_cache_size == 0) plugin_audio_cache_size = 2000; plugin_video_cache_size = gm_pref_store_get_int(gm_store, PLUGIN_VIDEO_CACHE_SIZE); if (plugin_video_cache_size == 0) plugin_video_cache_size = 2000; if (control_id != 0) cache_size = plugin_video_cache_size; gm_pref_store_free(gm_store); gm_pref_store_free(gmp_store); if (verbose && embed_window) { printf("embedded in window id 0x%x\n", embed_window); } if (verbose && single_instance) { printf("Running in single instance mode\n"); } #ifdef GIO_ENABLED if (verbose) { printf("Running with GIO support\n"); } #endif #ifdef ENABLE_PANSCAN if (verbose) { printf("Running with panscan enabled (mplayer svn r29565 or higher required)\n"); } #endif if (verbose) { printf("Using audio device: %s\n", audio_device_name); } if (softvol) { if (verbose) printf("Using MPlayer Software Volume control\n"); if (remember_softvol && volume_softvol != -1) { if (verbose) printf("Using last volume of %f%%\n", volume_softvol * 100.0); volume = (gdouble) volume_softvol *100.0; } else { volume = 100.0; } } if (large_buttons) button_size = GTK_ICON_SIZE_DIALOG; if (playlist_visible && control_id != 0) playlist_visible = FALSE; if (error != NULL) { printf("%s\n", error->message); printf(_("Run 'gnome-mplayer --help' to see a full list of available command line options.\n")); return 1; } // if (verbose) // printf("Threading support enabled = %i\n",g_thread_supported()); if (rpconsole == NULL) rpconsole = g_strdup("NONE"); // setup playliststore playliststore = gtk_list_store_new(N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_FLOAT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_FLOAT, G_TYPE_FLOAT, G_TYPE_BOOLEAN); // only use dark theme if not embedded, otherwise use the default theme #ifdef GTK3_ENABLED if (embed_window <= 0) { gtk_settings = gtk_settings_get_default(); g_object_set(G_OBJECT(gtk_settings), "gtk-application-prefer-dark-theme", TRUE, NULL); } #endif create_window(embed_window); autopause = FALSE; #ifdef GIO_ENABLED idledata->caching = g_mutex_new(); idledata->caching_complete = g_cond_new(); #endif retrieve_metadata_pool = g_thread_pool_new(retrieve_metadata, NULL, 10, TRUE, NULL); if (argv[fileindex] != NULL) { #ifdef GIO_ENABLED file = g_file_new_for_commandline_arg(argv[fileindex]); stat_result = -1; if (file != NULL) { GError *error = NULL; GFileInfo *file_info = g_file_query_info(file, G_FILE_ATTRIBUTE_UNIX_MODE, 0, NULL, &error); if (file_info != NULL) { buf.st_mode = g_file_info_get_attribute_uint32(file_info, G_FILE_ATTRIBUTE_UNIX_MODE); stat_result = 0; g_object_unref(file_info); } if (error != NULL) { if (verbose) printf("failed to get mode: %s\n", error->message); g_error_free(error); } g_object_unref(file); } #else stat_result = g_stat(argv[fileindex], &buf); #endif if (verbose) { printf("opening %s\n", argv[fileindex]); printf("stat_result = %i\n", stat_result); printf("is block %i\n", S_ISBLK(buf.st_mode)); printf("is character %i\n", S_ISCHR(buf.st_mode)); printf("is reg %i\n", S_ISREG(buf.st_mode)); printf("is dir %i\n", S_ISDIR(buf.st_mode)); printf("playlist %i\n", playlist); printf("embedded in window id 0x%x\n", embed_window); } if (stat_result == 0 && S_ISBLK(buf.st_mode)) { // might have a block device, so could be a DVD #ifdef HAVE_SYS_MOUNT_H fp = setmntent("/etc/mtab", "r"); do { mnt = getmntent(fp); if (mnt) printf("%s is at %s\n", mnt->mnt_fsname, mnt->mnt_dir); if (argv[fileindex] != NULL && mnt && mnt->mnt_fsname != NULL) { if (strcmp(argv[fileindex], mnt->mnt_fsname) == 0) break; } } while (mnt); endmntent(fp); #endif if (mnt && mnt->mnt_dir) { printf("%s is mounted on %s\n", argv[fileindex], mnt->mnt_dir); uri = g_strdup_printf("%s/VIDEO_TS", mnt->mnt_dir); stat(uri, &buf); g_free(uri); if (S_ISDIR(buf.st_mode)) { add_item_to_playlist("dvdnav://", 0); gtk_tree_model_get_iter_first(GTK_TREE_MODEL(playliststore), &iter); gmtk_media_player_set_media_type(GMTK_MEDIA_PLAYER(media), TYPE_DVD); //play_iter(&iter, 0); playiter = TRUE; } else { uri = g_strdup_printf("file://%s", mnt->mnt_dir); create_folder_progress_window(); add_folder_to_playlist_callback(uri, NULL); g_free(uri); destroy_folder_progress_window(); if (random_order) { gtk_tree_model_get_iter_first(GTK_TREE_MODEL(playliststore), &iter); randomize_playlist(playliststore); } if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(playliststore), &iter)) { // play_iter(&iter, 0); playiter = TRUE; } } } else { parse_cdda("cdda://"); if (random_order) { gtk_tree_model_get_iter_first(GTK_TREE_MODEL(playliststore), &iter); randomize_playlist(playliststore); } //play_file("cdda://", playlist); if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(playliststore), &iter)) { // play_iter(&iter, 0); playiter = TRUE; } } } else if (stat_result == 0 && S_ISDIR(buf.st_mode)) { uri = g_strdup_printf("%s/VIDEO_TS", argv[fileindex]); stat_result = g_stat(uri, &buf); g_free(uri); if (stat_result == 0 && S_ISDIR(buf.st_mode)) { add_item_to_playlist("dvdnav://", 0); gtk_tree_model_get_iter_first(GTK_TREE_MODEL(playliststore), &iter); gmtk_media_player_set_media_type(GMTK_MEDIA_PLAYER(media), TYPE_DVD); //play_iter(&iter, 0); playiter = TRUE; } else { create_folder_progress_window(); uri = NULL; #ifdef GIO_ENABLED file = g_file_new_for_commandline_arg(argv[fileindex]); if (file != NULL) { uri = g_file_get_uri(file); g_object_unref(file); } #else uri = g_filename_to_uri(argv[fileindex], NULL, NULL); #endif add_folder_to_playlist_callback(uri, NULL); g_free(uri); destroy_folder_progress_window(); if (random_order) { gtk_tree_model_get_iter_first(GTK_TREE_MODEL(playliststore), &iter); randomize_playlist(playliststore); } if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(playliststore), &iter)) { //play_iter(&iter, 0); playiter = TRUE; } } } else { // local file // detect if playlist here, so even if not specified it can be picked up i = fileindex; while (argv[i] != NULL) { if (verbose > 1) printf("Argument %i is %s\n", i, argv[i]); #ifdef GIO_ENABLED if (!device_name(argv[i])) { file = g_file_new_for_commandline_arg(argv[i]); if (file != NULL) { uri = g_file_get_uri(file); g_object_unref(file); } else { uri = g_strdup(argv[i]); } } else { uri = g_strdup(argv[i]); } #else uri = g_filename_to_uri(argv[i], NULL, NULL); #endif if (uri != NULL) { if (playlist == 0) playlist = detect_playlist(uri); if (!playlist) { add_item_to_playlist(uri, playlist); } else { if (!parse_playlist(uri)) { add_item_to_playlist(uri, playlist); } } g_free(uri); } i++; } if (random_order) { gtk_tree_model_get_iter_first(GTK_TREE_MODEL(playliststore), &iter); randomize_playlist(playliststore); } if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(playliststore), &iter)) { // play_iter(&iter, 0); playiter = TRUE; } } } #ifdef HAVE_GPOD if (load_tracks_from_gpod) { gpod_mount_point = find_gpod_mount_point(); printf("mount point is %s\n", gpod_mount_point); if (gpod_mount_point != NULL) { gpod_load_tracks(gpod_mount_point); } else { printf("Unable to find gpod mount point\n"); } } #endif gm_audio_update_device(&audio_device); gm_audio_get_volume(&audio_device); gm_audio_set_server_volume_update_callback(&audio_device, set_volume); set_media_player_attributes(media); if (!softvol) { if (pref_volume != -1) { audio_device.volume = (gdouble) pref_volume / 100.0; } if (verbose) printf("The volume on '%s' is %f\n", audio_device.description, audio_device.volume); volume = audio_device.volume * 100; } else { audio_device.volume = volume / 100.0; } #ifdef GTK2_12_ENABLED gtk_scale_button_set_value(GTK_SCALE_BUTTON(vol_slider), audio_device.volume); #else gtk_range_set_value(GTK_RANGE(vol_slider), audio_device.volume); #endif use_volume_option = detect_volume_option(); dbus_hookup(embed_window, control_id); show_window(embed_window); if (playiter) play_iter(&iter, 0); if (argv[fileindex] == NULL && embed_window == 0) { // When running as apple.com external player, don't load the default playlist if (control_id == 0) { use_remember_loc = remember_loc; gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem_view_playlist), playlist_visible); } else { remember_loc = FALSE; use_remember_loc = FALSE; // prevents saving of a playlist with one item on it use_defaultpl = FALSE; // don't save the loc when launched with a single file save_loc = FALSE; } } else { // prevents saving of a playlist with one item on it use_defaultpl = FALSE; // don't save the loc when launched with a single file save_loc = FALSE; } if (single_instance && embed_window == 0) { if (control_id == 0) { use_remember_loc = remember_loc; gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem_view_playlist), playlist_visible); } } if (embed_window == 0) { if (remember_loc) { gtk_window_move(GTK_WINDOW(window), loc_window_x, loc_window_y); g_idle_add(set_pane_position, NULL); } } safe_to_save_default_playlist = FALSE; if (use_defaultpl) { create_folder_progress_window(); parse_playlist(default_playlist); destroy_folder_progress_window(); } safe_to_save_default_playlist = TRUE; gtk_main(); return 0; }
bool partMover::entry_update(partMover *currentPart) { GdkColor color_black; GdkColor color_grey; GdkColor color_yellow; GdkColor color_green; GdkColor color_green_blue; GdkColor color_dark_green; GdkColor color_red; GdkColor color_fault_red; GdkColor color_pink; GdkColor color_indaco; GdkColor color_white; GdkColor color_blue; color_pink.red=219*255; color_pink.green=166*255; color_pink.blue=171*255; color_fault_red.red=255*255; color_fault_red.green=10*255; color_fault_red.blue=10*255; color_black.red=10*255; color_black.green=10*255; color_black.blue=10*255; color_red.red=255*255; color_red.green=100*255; color_red.blue=100*255; color_grey.red=220*255; color_grey.green=220*255; color_grey.blue=220*255; color_white.red=250*255; color_white.green=250*255; color_white.blue=250*255; color_green.red=149*255; color_green.green=221*255; color_green.blue=186*255; color_dark_green.red=(149-30)*255; color_dark_green.green=(221-30)*255; color_dark_green.blue=(186-30)*255; color_blue.red=150*255; color_blue.green=190*255; color_blue.blue=255*255; color_green_blue.red=(149+150)/2*255; color_green_blue.green=(221+190)/2*255; color_green_blue.blue=(186+255)/2*255; color_indaco.red=220*255; color_indaco.green=190*255; color_indaco.blue=220*255; color_yellow.red=249*255; color_yellow.green=236*255; color_yellow.blue=141*255; GdkColor* pColor= &color_grey; static int slowSwitcher = 0; IControlMode *ictrl = currentPart->ctrlmode2; IInteractionMode *iint = currentPart->iinteract; IPositionControl *ipos = currentPart->pos; IVelocityControl *ivel = currentPart->iVel; IPositionDirect *iDir = currentPart->iDir; IEncoders *iiencs = currentPart->iencs; ITorqueControl *itrq = currentPart->trq; IAmplifierControl *iamp = currentPart->amp; GtkEntry * *pos_entry = (GtkEntry **) currentPart->currPosArray; GtkEntry **trq_entry = (GtkEntry **) currentPart->currTrqArray; GtkEntry **speed_entry = (GtkEntry **) currentPart->currSpeedArray; GtkEntry **inEntry = (GtkEntry **) currentPart->inPosArray; GtkWidget **colorback = (GtkWidget **) currentPart->frameColorBack; GtkWidget **sliderAry = currentPart->sliderArray; bool *POS_UPDATE = currentPart->CURRENT_POS_UPDATE; char buffer[40] = {'i', 'n', 'i', 't'}; char frame_title [255]; double positions[MAX_NUMBER_OF_JOINTS]; double torques[MAX_NUMBER_OF_JOINTS]; double speeds[MAX_NUMBER_OF_JOINTS]; double max_torques[MAX_NUMBER_OF_JOINTS]; double min_torques[MAX_NUMBER_OF_JOINTS]; static int controlModes[MAX_NUMBER_OF_JOINTS]; static int controlModesOld[MAX_NUMBER_OF_JOINTS]; static yarp::dev::InteractionModeEnum interactionModes[MAX_NUMBER_OF_JOINTS]; static yarp::dev::InteractionModeEnum interactionModesOld[MAX_NUMBER_OF_JOINTS]; int k; int NUMBER_OF_JOINTS=0; bool done = false; bool ret = false; ipos->getAxes(&NUMBER_OF_JOINTS); if (NUMBER_OF_JOINTS == 0) { fprintf(stderr,"Lost connection with iCubInterface. You should save and restart.\n" ); Time::delay(0.1); pColor=&color_grey; strcpy(frame_title,"DISCONNECTED"); for (k = 0; k < MAX_NUMBER_OF_JOINTS; k++) { if (currentPart->framesArray[k]!=0) { gtk_frame_set_label (GTK_FRAME(currentPart->framesArray[k]),frame_title); gtk_widget_modify_bg (colorback[k], GTK_STATE_NORMAL, pColor); } } return true; } for (k = 0; k < NUMBER_OF_JOINTS; k++) { max_torques[k]=0; min_torques[k]=0; torques[k]=0; } if (!iiencs->getEncoders(positions)) return true; itrq->getTorques(torques); iiencs->getEncoderSpeeds(speeds); //update all joints positions for (k = 0; k < NUMBER_OF_JOINTS; k++) { sprintf(buffer, "%.1f", positions[k]); gtk_entry_set_text((GtkEntry*) pos_entry[k], buffer); sprintf(buffer, "%.3f", torques[k]); gtk_entry_set_text((GtkEntry*) trq_entry[k], buffer); sprintf(buffer, "%.1f", speeds[k]); gtk_entry_set_text((GtkEntry*) speed_entry[k], buffer); } //update all joint sliders for (k = 0; k < NUMBER_OF_JOINTS; k++) if(POS_UPDATE[k]) gtk_range_set_value((GtkRange*)sliderAry[k], positions[k]); // *** update the checkMotionDone box section *** // (only one at a time in order to save badwidth) k = slowSwitcher%NUMBER_OF_JOINTS; slowSwitcher++; #if DEBUG_GUI gtk_entry_set_text((GtkEntry*) inEntry[k], "off"); #else ipos->checkMotionDone(k, &done); if (!done) gtk_entry_set_text((GtkEntry*) inEntry[k], " "); else gtk_entry_set_text((GtkEntry*) inEntry[k], "@"); #endif // *** update the controlMode section *** // the new icubinterface does not increase the bandwidth consumption // ret = true; useless guys! ret=ictrl->getControlModes(controlModes); if (ret==false) fprintf(stderr,"ictrl->getControlMode failed\n" ); ret=iint->getInteractionModes(interactionModes); if (ret==false) fprintf(stderr,"iint->getInteractionlMode failed\n" ); for (k = 0; k < NUMBER_OF_JOINTS; k++) { if (currentPart->first_time==false && controlModes[k] == controlModesOld[k]) continue; controlModesOld[k]=controlModes[k]; sprintf(frame_title,"Joint %d ",k ); switch (controlModes[k]) { case VOCAB_CM_IDLE: pColor=&color_yellow; strcat(frame_title," (IDLE)"); gtk_frame_set_label (GTK_FRAME(currentPart->framesArray[k]),frame_title); gtk_widget_modify_bg (colorback[k], GTK_STATE_NORMAL, pColor); break; case VOCAB_CM_POSITION: pColor=&color_green; strcat(frame_title," (POSITION)"); gtk_frame_set_label (GTK_FRAME(currentPart->framesArray[k]),frame_title); gtk_frame_set_label (GTK_FRAME(currentPart->frame_slider1[k]),"Position:"); gtk_frame_set_label (GTK_FRAME(currentPart->frame_slider2[k]),"Velocity:"); gtk_widget_modify_bg (colorback[k], GTK_STATE_NORMAL, pColor); break; case VOCAB_CM_POSITION_DIRECT: pColor=&color_dark_green; strcat(frame_title," (POSITION_DIRECT)"); gtk_frame_set_label (GTK_FRAME(currentPart->framesArray[k]),frame_title); gtk_frame_set_label (GTK_FRAME(currentPart->frame_slider1[k]),"Position:"); gtk_frame_set_label (GTK_FRAME(currentPart->frame_slider2[k]),"---"); gtk_widget_modify_bg (colorback[k], GTK_STATE_NORMAL, pColor); break; case VOCAB_CM_MIXED: pColor=&color_green_blue; strcat(frame_title," (MIXED_MODE)"); gtk_frame_set_label (GTK_FRAME(currentPart->framesArray[k]),frame_title); gtk_frame_set_label (GTK_FRAME(currentPart->frame_slider1[k]),"Position:"); gtk_frame_set_label (GTK_FRAME(currentPart->frame_slider2[k]),"Velocity"); gtk_widget_modify_bg (colorback[k], GTK_STATE_NORMAL, pColor); break; case VOCAB_CM_VELOCITY: pColor=&color_blue; strcat(frame_title," (VELOCITY)"); gtk_frame_set_label (GTK_FRAME(currentPart->framesArray[k]),frame_title); gtk_widget_modify_bg (colorback[k], GTK_STATE_NORMAL, pColor); break; case VOCAB_CM_TORQUE: pColor=&color_pink; strcat(frame_title," (TORQUE)"); gtk_frame_set_label (GTK_FRAME(currentPart->framesArray[k]),frame_title); gtk_frame_set_label (GTK_FRAME(currentPart->frame_slider1[k]),"Torque:"); gtk_frame_set_label (GTK_FRAME(currentPart->frame_slider2[k]),"Torque2:"); gtk_widget_modify_bg (colorback[k], GTK_STATE_NORMAL, pColor); break; case VOCAB_CM_IMPEDANCE_POS: pColor=&color_indaco; strcat(frame_title," (IMPEDANCE POS)"); gtk_frame_set_label (GTK_FRAME(currentPart->framesArray[k]),frame_title); gtk_widget_modify_bg (colorback[k], GTK_STATE_NORMAL, pColor); break; case VOCAB_CM_IMPEDANCE_VEL: pColor=&color_indaco; strcat(frame_title," (IMPEDANCE VEL)"); gtk_frame_set_label (GTK_FRAME(currentPart->framesArray[k]),frame_title); gtk_widget_modify_bg (colorback[k], GTK_STATE_NORMAL, pColor); break; case VOCAB_CM_OPENLOOP: pColor=&color_white; strcat(frame_title," (OPENLOOP)"); gtk_frame_set_label (GTK_FRAME(currentPart->framesArray[k]),frame_title); gtk_widget_modify_bg (colorback[k], GTK_STATE_NORMAL, pColor); break; case VOCAB_CM_HW_FAULT: pColor=&color_fault_red; strcat(frame_title," (HARDWARE_FAULT)"); gtk_frame_set_label (GTK_FRAME(currentPart->framesArray[k]),frame_title); gtk_frame_set_label (GTK_FRAME(currentPart->frame_slider1[k]),"---"); gtk_frame_set_label (GTK_FRAME(currentPart->frame_slider2[k]),"---"); gtk_widget_modify_bg (colorback[k], GTK_STATE_NORMAL, pColor); break; case VOCAB_CM_CALIBRATING: pColor=&color_grey; strcat(frame_title," (CALIBRATING)"); gtk_frame_set_label (GTK_FRAME(currentPart->framesArray[k]),frame_title); gtk_widget_modify_bg (colorback[k], GTK_STATE_NORMAL, pColor); break; case VOCAB_CM_CALIB_DONE: pColor=&color_grey; strcat(frame_title," (CALIB DONE)"); gtk_frame_set_label (GTK_FRAME(currentPart->framesArray[k]),frame_title); gtk_widget_modify_bg (colorback[k], GTK_STATE_NORMAL, pColor); break; case VOCAB_CM_NOT_CONFIGURED: pColor=&color_grey; strcat(frame_title," (NOT CONFIGURED)"); gtk_frame_set_label (GTK_FRAME(currentPart->framesArray[k]),frame_title); gtk_widget_modify_bg (colorback[k], GTK_STATE_NORMAL, pColor); break; case VOCAB_CM_CONFIGURED: pColor=&color_grey; strcat(frame_title," (CONFIGURED)"); gtk_frame_set_label (GTK_FRAME(currentPart->framesArray[k]),frame_title); gtk_widget_modify_bg (colorback[k], GTK_STATE_NORMAL, pColor); break; default: case VOCAB_CM_UNKNOWN: pColor=&color_grey; strcat(frame_title," (UNKNOWN)"); gtk_frame_set_label (GTK_FRAME(currentPart->framesArray[k]),frame_title); gtk_widget_modify_bg (colorback[k], GTK_STATE_NORMAL, pColor); break; } } for (k = 0; k < NUMBER_OF_JOINTS; k++) { if (currentPart->first_time==false && interactionModes[k] == interactionModesOld[k]) continue; interactionModesOld[k]=interactionModes[k]; switch (interactionModes[k]) { case VOCAB_IM_STIFF: gtk_widget_modify_base ((GtkWidget*)inEntry[k], GTK_STATE_NORMAL, &color_green); break; case VOCAB_IM_COMPLIANT: gtk_widget_modify_base ((GtkWidget*)inEntry[k], GTK_STATE_NORMAL, &color_fault_red); break; default: case VOCAB_CM_UNKNOWN: gtk_widget_modify_base ((GtkWidget*)inEntry[k], GTK_STATE_NORMAL, &color_white); break; } } currentPart->first_time =false; return true; }
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; }
int main (int argc, char *argv[]) { GstElement *bin; GstElement *src, *spectrum, *audioconvert, *sink; GstBus *bus; GtkWidget *appwindow, *vbox, *widget; gst_init (&argc, &argv); gtk_init (&argc, &argv); bin = gst_pipeline_new ("bin"); src = gst_element_factory_make ("audiotestsrc", "src"); g_object_set (G_OBJECT (src), "wave", 0, NULL); spectrum = gst_element_factory_make ("spectrum", "spectrum"); g_object_set (G_OBJECT (spectrum), "bands", spect_bands, "threshold", -80, "message", TRUE, NULL); audioconvert = gst_element_factory_make ("audioconvert", "audioconvert"); sink = gst_element_factory_make (DEFAULT_AUDIOSINK, "sink"); gst_bin_add_many (GST_BIN (bin), src, spectrum, audioconvert, sink, NULL); if (!gst_element_link_many (src, spectrum, audioconvert, sink, NULL)) { fprintf (stderr, "can't link elements\n"); exit (1); } bus = gst_element_get_bus (bin); gst_bus_add_watch (bus, message_handler, NULL); gst_object_unref (bus); sync_clock = gst_pipeline_get_clock (GST_PIPELINE (bin)); appwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect (G_OBJECT (appwindow), "destroy", G_CALLBACK (on_window_destroy), NULL); vbox = gtk_vbox_new (FALSE, 6); widget = gtk_hscale_new_with_range (50.0, 20000.0, 10); gtk_scale_set_draw_value (GTK_SCALE (widget), TRUE); gtk_scale_set_value_pos (GTK_SCALE (widget), GTK_POS_TOP); gtk_range_set_value (GTK_RANGE (widget), 440.0); g_signal_connect (G_OBJECT (widget), "value-changed", G_CALLBACK (on_frequency_changed), (gpointer) src); gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); drawingarea = gtk_drawing_area_new (); gtk_widget_set_size_request (drawingarea, spect_bands, spect_height); g_signal_connect (G_OBJECT (drawingarea), "configure-event", G_CALLBACK (on_configure_event), (gpointer) spectrum); gtk_box_pack_start (GTK_BOX (vbox), drawingarea, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (appwindow), vbox); gtk_widget_show_all (appwindow); gst_element_set_state (bin, GST_STATE_PLAYING); gtk_main (); gst_element_set_state (bin, GST_STATE_NULL); gst_object_unref (sync_clock); gst_object_unref (bin); return 0; }
void shoes_native_slot_scroll_top(SHOES_SLOT_OS *slot) { if (slot->vscroll) gtk_range_set_value(GTK_RANGE(slot->vscroll), slot->scrolly); }
void DisplayDialog() { int return_value; GtkWidget *dialog, *main_label, *adv_box; GtkWidget *default_button; ReadSettings(); /* Create the widgets */ dialog = gtk_dialog_new_with_buttons( "Advanced Settings", NULL, /* parent window*/ (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), "Cancel", GTK_RESPONSE_REJECT, "OK", GTK_RESPONSE_ACCEPT, NULL); main_label = gtk_label_new("These are advanced configuration options for fine tuning time stretching behavior. \nLarger values are better for slowdown, while smaller values are better for speedup (more then 60 fps.). \nAll options are in microseconds."); gtk_label_set_line_wrap(GTK_LABEL(main_label), true); default_button = gtk_button_new_with_label("Reset to Defaults"); seq_label = gtk_label_new("Sequence Length"); seq_slide = spu2x_gtk_hscale_new_with_range(SequenceLen_Min, SequenceLen_Max, 2); gtk_range_set_value(GTK_RANGE(seq_slide), SequenceLenMS); seek_label = gtk_label_new("Seek Window Size"); seek_slide = spu2x_gtk_hscale_new_with_range(SeekWindow_Min, SeekWindow_Max, 2); gtk_range_set_value(GTK_RANGE(seek_slide), SeekWindowMS); over_label = gtk_label_new("Overlap"); over_slide = spu2x_gtk_hscale_new_with_range(Overlap_Min, Overlap_Max, 2); gtk_range_set_value(GTK_RANGE(over_slide), OverlapMS); adv_box = spu2x_gtk_vbox_new(5); gtk_box_pack_start(GTK_BOX(adv_box), main_label, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(adv_box), default_button, TRUE, TRUE, 5); gtk_box_pack_start(GTK_BOX(adv_box), seq_label, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(adv_box), seq_slide, TRUE, TRUE, 5); gtk_box_pack_start(GTK_BOX(adv_box), seek_label, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(adv_box), seek_slide, TRUE, TRUE, 5); gtk_box_pack_start(GTK_BOX(adv_box), over_label, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(adv_box), over_slide, TRUE, TRUE, 5); gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), adv_box); g_signal_connect_swapped(default_button, "clicked", G_CALLBACK(restore_defaults), default_button); gtk_widget_show_all(dialog); return_value = gtk_dialog_run(GTK_DIALOG(dialog)); if (return_value == GTK_RESPONSE_ACCEPT) { SequenceLenMS = gtk_range_get_value(GTK_RANGE(seq_slide)); SeekWindowMS = gtk_range_get_value(GTK_RANGE(seek_slide)); OverlapMS = gtk_range_get_value(GTK_RANGE(over_slide)); } gtk_widget_destroy(dialog); WriteSettings(); }
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; }
void pHexEdit::updateScroll() { unsigned row = hexEdit.state.offset / hexEdit.state.columns; gtk_range_set_value(GTK_RANGE(scrollBar), row); }
/** \brief Create and initialise time controller widgets. * \param module The parent GtkSatModule * */ void tmg_create (GtkSatModule *mod) { GtkWidget *vbox, *hbox, *table; GtkWidget *image; GtkWidget *label; gchar *title; gchar *buff; /* make sure controller is not already active */ if (mod->tmgActive) { sat_log_log (SAT_LOG_LEVEL_INFO, _("%s: Time Controller for %s is already active"), __FUNCTION__, mod->name); /* try to make window visible in case it is covered by something else */ gtk_window_present (GTK_WINDOW (mod->tmgWin)); return; } /* create hbox containing the controls the controls are implemented as radiobuttons in order to inherit the mutual exclusion behaviour */ hbox = gtk_hbox_new (FALSE, 0); /* FWD */ mod->tmgFwd = gtk_radio_button_new (NULL); gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (mod->tmgFwd), FALSE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mod->tmgFwd), TRUE); image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_FORWARD, GTK_ICON_SIZE_BUTTON); gtk_container_add (GTK_CONTAINER (mod->tmgFwd), image); gtk_widget_set_tooltip_text (mod->tmgFwd, _("Play forward")); g_signal_connect (mod->tmgFwd, "toggled", G_CALLBACK (tmg_fwd), mod); gtk_box_pack_end (GTK_BOX (hbox), mod->tmgFwd, FALSE, FALSE, 0); /* STOP */ mod->tmgStop = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (mod->tmgFwd)); gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (mod->tmgStop), FALSE); image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_PAUSE, GTK_ICON_SIZE_BUTTON); gtk_container_add (GTK_CONTAINER (mod->tmgStop), image); gtk_widget_set_tooltip_text (mod->tmgStop, _("Stop")); g_signal_connect (mod->tmgStop, "toggled", G_CALLBACK (tmg_stop), mod); gtk_box_pack_end (GTK_BOX (hbox), mod->tmgStop, FALSE, FALSE, 0); /* BWD */ mod->tmgBwd = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (mod->tmgFwd)); gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (mod->tmgBwd), FALSE); image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_REWIND, GTK_ICON_SIZE_BUTTON); gtk_container_add (GTK_CONTAINER (mod->tmgBwd), image); gtk_widget_set_tooltip_text (mod->tmgBwd, _("Play backwards")); g_signal_connect (mod->tmgBwd, "toggled", G_CALLBACK (tmg_bwd), mod); gtk_box_pack_end (GTK_BOX (hbox), mod->tmgBwd, FALSE, FALSE, 0); /* reset time */ mod->tmgReset = gtk_button_new_with_label (_("Reset")); gtk_widget_set_tooltip_text (mod->tmgReset, _("Reset to current date and time")); g_signal_connect (mod->tmgReset, "clicked", G_CALLBACK (tmg_reset), mod); gtk_box_pack_end (GTK_BOX (hbox), mod->tmgReset, FALSE, FALSE, 10); /* status label */ mod->tmgState = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (mod->tmgState), 0.0, 0.5); gtk_label_set_markup (GTK_LABEL (mod->tmgState), _("<b>Real-Time</b>")); gtk_box_pack_start (GTK_BOX (hbox), mod->tmgState, TRUE, TRUE, 10); /* create table containing the date and time widgets */ table = gtk_table_new (5, 3, FALSE); gtk_table_set_row_spacings (GTK_TABLE (table), 0); mod->tmgCal = gtk_calendar_new (); gtk_calendar_set_display_options (GTK_CALENDAR (mod->tmgCal), GTK_CALENDAR_SHOW_HEADING | GTK_CALENDAR_SHOW_DAY_NAMES | GTK_CALENDAR_WEEK_START_MONDAY); g_signal_connect (mod->tmgCal, "day-selected", G_CALLBACK (tmg_time_set), mod); gtk_table_attach (GTK_TABLE (table), mod->tmgCal, 0, 1, 0, 5, GTK_SHRINK, GTK_SHRINK, 0, 0); /* Time controllers. Note that the controllers for hours, minutes, and seconds have ranges; however, they can wrap around their limits in order to ensure a smooth and continuous control of the time */ /* hour */ label = gtk_label_new (_(" Hour:")); gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); gtk_table_attach (GTK_TABLE (table), label, 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 5, 0); mod->tmgHour = gtk_spin_button_new_with_range (0, 23, 1); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (mod->tmgHour), TRUE); gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (mod->tmgHour), GTK_UPDATE_IF_VALID); gtk_spin_button_set_digits (GTK_SPIN_BUTTON (mod->tmgHour), 0); gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (mod->tmgHour), TRUE); //FIXME gtk_spin_button_set_value (GTK_SPIN_BUTTON (mod->tmgHour), 2); gtk_widget_set_tooltip_text (mod->tmgHour, _("Use this control to set the hour")); g_signal_connect (mod->tmgHour, "value-changed", G_CALLBACK (tmg_time_set), mod); g_signal_connect (mod->tmgHour, "wrapped", G_CALLBACK (tmg_hour_wrap), mod); gtk_table_attach (GTK_TABLE (table), mod->tmgHour, 2, 3, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0); /* minutes */ label = gtk_label_new (_(" Min:")); gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); gtk_table_attach (GTK_TABLE (table), label, 1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 5, 0); mod->tmgMin = gtk_spin_button_new_with_range (0, 59, 1); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (mod->tmgMin), TRUE); gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (mod->tmgMin), GTK_UPDATE_IF_VALID); gtk_spin_button_set_digits (GTK_SPIN_BUTTON (mod->tmgMin), 0); gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (mod->tmgMin), TRUE); //FIXME gtk_spin_button_set_value (GTK_SPIN_BUTTON (mod->tmgMin), 2); gtk_widget_set_tooltip_text (mod->tmgMin, _("Use this control to set the minutes")); g_signal_connect (mod->tmgMin, "value-changed", G_CALLBACK (tmg_time_set), mod); g_signal_connect (mod->tmgMin, "wrapped", G_CALLBACK (tmg_min_wrap), mod); gtk_table_attach (GTK_TABLE (table), mod->tmgMin, 2, 3, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0); /* seconds */ label = gtk_label_new (_(" Sec:")); gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); gtk_table_attach (GTK_TABLE (table), label, 1, 2, 2, 3, GTK_SHRINK, GTK_SHRINK, 5, 0); mod->tmgSec = gtk_spin_button_new_with_range (0, 59, 1); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (mod->tmgSec), TRUE); gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (mod->tmgSec), GTK_UPDATE_IF_VALID); gtk_spin_button_set_digits (GTK_SPIN_BUTTON (mod->tmgSec), 0); gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (mod->tmgSec), TRUE); //FIXME gtk_spin_button_set_value (GTK_SPIN_BUTTON (mod->tmgSec), 2); gtk_widget_set_tooltip_text (mod->tmgSec, _("Use this control to set the seconds")); g_signal_connect (mod->tmgSec, "value-changed", G_CALLBACK (tmg_time_set), mod); g_signal_connect (mod->tmgSec, "wrapped", G_CALLBACK (tmg_sec_wrap), mod); gtk_table_attach (GTK_TABLE (table), mod->tmgSec, 2, 3, 2, 3, GTK_SHRINK, GTK_SHRINK, 0, 0); /* milliseconds */ label = gtk_label_new (_(" Msec:")); gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); gtk_table_attach (GTK_TABLE (table), label, 1, 2, 3, 4, GTK_SHRINK, GTK_SHRINK, 5, 0); mod->tmgMsec = gtk_spin_button_new_with_range (0, 999, 1); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (mod->tmgMsec), TRUE); gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (mod->tmgMsec), GTK_UPDATE_IF_VALID); gtk_spin_button_set_digits (GTK_SPIN_BUTTON (mod->tmgMsec), 0); gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (mod->tmgMsec), TRUE); //FIXME gtk_spin_button_set_value (GTK_SPIN_BUTTON (mod->tmgMsec), 2); gtk_widget_set_tooltip_text (mod->tmgMsec, _("Use this control to set the milliseconds")); g_signal_connect (mod->tmgMsec, "value-changed", G_CALLBACK (tmg_time_set), mod); g_signal_connect (mod->tmgMsec, "wrapped", G_CALLBACK (tmg_msec_wrap), mod); gtk_table_attach (GTK_TABLE (table), mod->tmgMsec, 2, 3, 3, 4, GTK_SHRINK, GTK_SHRINK, 0, 0); /* time throttle */ label = gtk_label_new (_("Throttle:")); gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); gtk_table_attach (GTK_TABLE (table), label, 1, 2, 4, 5, GTK_SHRINK, GTK_SHRINK, 5, 0); mod->tmgFactor = gtk_spin_button_new_with_range (1, 100, 1); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (mod->tmgFactor), TRUE); gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (mod->tmgFactor), GTK_UPDATE_IF_VALID); gtk_spin_button_set_digits (GTK_SPIN_BUTTON (mod->tmgFactor), 0); gtk_spin_button_set_value (GTK_SPIN_BUTTON (mod->tmgFactor), 1); gtk_widget_set_tooltip_text (mod->tmgFactor, _("Time throttle / compression factor")); g_signal_connect (mod->tmgFactor, "value-changed", G_CALLBACK (tmg_throttle), mod); gtk_table_attach (GTK_TABLE (table), mod->tmgFactor, 2, 3, 4, 5, GTK_SHRINK, GTK_SHRINK, 0, 0); /* add slider */ mod->tmgSlider = gtk_hscale_new_with_range (-0.1, +0.1, 0.0001); // +/- 2.5 hr /*gtk_widget_set_tooltip_text (mod->tmgSlider, _("Drag the slider to change the time up to +/- 2.5 hours.\n"\ "Resolution is ~ 8 seconds."));*/ gtk_scale_set_draw_value (GTK_SCALE (mod->tmgSlider), FALSE); gtk_range_set_value (GTK_RANGE (mod->tmgSlider), 0.0); g_signal_connect (mod->tmgSlider, "value-changed", G_CALLBACK (slider_moved), mod); /* create the vertical box */ vbox = gtk_vbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), mod->tmgSlider, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new(), FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); /* create main window */ mod->tmgWin = gtk_window_new (GTK_WINDOW_TOPLEVEL); title = g_strconcat (_("Time Controller"), " / ", mod->name, NULL); gtk_window_set_title (GTK_WINDOW (mod->tmgWin), title); g_free (title); gtk_window_set_transient_for (GTK_WINDOW (mod->tmgWin), GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (mod)))); g_signal_connect (G_OBJECT (mod->tmgWin), "delete_event", G_CALLBACK (tmg_delete), mod); g_signal_connect (G_OBJECT (mod->tmgWin), "destroy", G_CALLBACK (tmg_destroy), mod); /* window icon */ buff = icon_file_name ("gpredict-clock.png"); gtk_window_set_icon_from_file (GTK_WINDOW (mod->tmgWin), buff, NULL); g_free (buff); gtk_container_add (GTK_CONTAINER (mod->tmgWin), vbox); gtk_widget_show_all (mod->tmgWin); mod->tmgActive = TRUE; sat_log_log (SAT_LOG_LEVEL_INFO, _("%s: Time Controller for %s launched"), __FUNCTION__, mod->name); }
static GtkWidget * build_dialog (VnrPrefs *prefs) { GtkBuilder *builder; GtkWidget *window; GError *error = NULL; GObject *close_button; GtkToggleButton *show_hidden; GtkToggleButton *fit_on_fullscreen; GtkBox *zoom_mode_box; GtkComboBox *zoom_mode; GtkToggleButton *smooth_images; GtkToggleButton *confirm_delete; GtkToggleButton *reload_on_save; GtkSpinButton *slideshow_timeout; GtkTable *behavior_table; GtkComboBox *action_wheel; GtkComboBox *action_click; GtkComboBox *action_modify; GtkRange *jpeg_scale; GtkRange *png_scale; builder = gtk_builder_new (); gtk_builder_add_from_file (builder, UI_PATH, &error); if (error != NULL) { g_warning ("%s\n", error->message); g_object_unref(builder); return NULL; } window = GTK_WIDGET (gtk_builder_get_object (builder, "window")); /* Close button */ close_button = gtk_builder_get_object (builder, "close_button"); g_signal_connect_swapped(close_button, "clicked", G_CALLBACK(gtk_widget_hide_on_delete), window); /* Show hidden files checkbox */ show_hidden = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "show_hidden")); gtk_toggle_button_set_active( show_hidden, prefs->show_hidden ); g_signal_connect(G_OBJECT(show_hidden), "toggled", G_CALLBACK(toggle_show_hidden_cb), prefs); /* Fit on fullscreen checkbox */ fit_on_fullscreen = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "fit_on_fullscreen")); gtk_toggle_button_set_active( fit_on_fullscreen, prefs->fit_on_fullscreen ); g_signal_connect(G_OBJECT(fit_on_fullscreen), "toggled", G_CALLBACK(toggle_fit_on_fullscreen_cb), prefs); /* Smooth images checkbox */ smooth_images = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "smooth_images")); gtk_toggle_button_set_active( smooth_images, prefs->smooth_images ); g_signal_connect(G_OBJECT(smooth_images), "toggled", G_CALLBACK(toggle_smooth_images_cb), prefs); /* Confirm delete checkbox */ confirm_delete = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "confirm_delete")); gtk_toggle_button_set_active( confirm_delete, prefs->confirm_delete ); g_signal_connect(G_OBJECT(confirm_delete), "toggled", G_CALLBACK(toggle_confirm_delete_cb), prefs); /* Reload image after save checkbox */ reload_on_save = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "reload")); gtk_toggle_button_set_active( reload_on_save, prefs->reload_on_save ); g_signal_connect(G_OBJECT(reload_on_save), "toggled", G_CALLBACK(toggle_reload_on_save_cb), prefs); /* Slideshow timeout spin button */ slideshow_timeout = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, "slideshow_timeout")); gtk_spin_button_set_value( slideshow_timeout, (gdouble)prefs->slideshow_timeout); prefs->slideshow_timeout_widget = slideshow_timeout; g_signal_connect(G_OBJECT(slideshow_timeout), "value-changed", G_CALLBACK(change_spin_value_cb), prefs); /* JPEG quality scale */ jpeg_scale = GTK_RANGE (gtk_builder_get_object (builder, "jpeg_scale")); gtk_range_set_value(jpeg_scale, (gdouble)prefs->jpeg_quality); g_signal_connect(G_OBJECT(jpeg_scale), "value-changed", G_CALLBACK(change_jpeg_quality_cb), prefs); /* PNG compression scale */ png_scale = GTK_RANGE (gtk_builder_get_object (builder, "png_scale")); gtk_range_set_value(png_scale, (gdouble)prefs->png_compression); g_signal_connect(G_OBJECT(png_scale), "value-changed", G_CALLBACK(change_png_compression_cb), prefs); /* Zoom mode combo box */ zoom_mode_box = GTK_BOX (gtk_builder_get_object (builder, "zoom_mode_box")); zoom_mode = (GtkComboBox*) gtk_combo_box_new_text(); gtk_combo_box_append_text(zoom_mode, _("Smart Mode")); gtk_combo_box_append_text(zoom_mode, _("1:1 Mode")); gtk_combo_box_append_text(zoom_mode, _("Fit To Window Mode")); gtk_combo_box_append_text(zoom_mode, _("Last Used Mode")); gtk_combo_box_set_active(zoom_mode, prefs->zoom); gtk_box_pack_end (zoom_mode_box, GTK_WIDGET(zoom_mode), FALSE, FALSE, 0); gtk_widget_show(GTK_WIDGET(zoom_mode)); g_signal_connect(G_OBJECT(zoom_mode), "changed", G_CALLBACK(change_zoom_mode_cb), prefs); /* Behavior combo boxes */ behavior_table = GTK_TABLE (gtk_builder_get_object (builder, "behavior_table")); action_wheel = (GtkComboBox*) gtk_combo_box_new_text(); gtk_combo_box_append_text(action_wheel, _("Navigate images")); gtk_combo_box_append_text(action_wheel, _("Zoom image")); gtk_combo_box_append_text(action_wheel, _("Scroll image up/down")); gtk_combo_box_set_active(action_wheel, prefs->behavior_wheel); gtk_table_attach (behavior_table, GTK_WIDGET(action_wheel), 1,2,0,1, GTK_FILL,0, 0,0); gtk_widget_show(GTK_WIDGET(action_wheel)); g_signal_connect(G_OBJECT(action_wheel), "changed", G_CALLBACK(change_action_wheel_cb), prefs); action_click = (GtkComboBox*) gtk_combo_box_new_text(); gtk_combo_box_append_text(action_click, _("Switch zoom modes")); gtk_combo_box_append_text(action_click, _("Enter fullscreen mode")); gtk_combo_box_append_text(action_click, _("Navigate images")); gtk_combo_box_set_active(action_click, prefs->behavior_click); gtk_table_attach (behavior_table, GTK_WIDGET(action_click), 1,2,1,2, GTK_FILL,0, 0,0); gtk_widget_show(GTK_WIDGET(action_click)); g_signal_connect(G_OBJECT(action_click), "changed", G_CALLBACK(change_action_click_cb), prefs); action_modify = (GtkComboBox*) gtk_combo_box_new_text(); gtk_combo_box_append_text(action_modify, _("Ask every time")); gtk_combo_box_append_text(action_modify, _("Autosave")); gtk_combo_box_append_text(action_modify, _("Ignore changes")); gtk_combo_box_set_active(action_modify, prefs->behavior_modify); gtk_table_attach (behavior_table, GTK_WIDGET(action_modify), 1,2,2,3, GTK_FILL,0, 0,0); gtk_widget_show(GTK_WIDGET(action_modify)); g_signal_connect(G_OBJECT(action_modify), "changed", G_CALLBACK(change_action_modify_cb), prefs); /* Window signals */ g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), NULL); g_signal_connect(G_OBJECT(window), "key-press-event", G_CALLBACK(key_press_cb), NULL); g_object_unref (G_OBJECT (builder)); return window; }
static void xfburn_preferences_dialog_init (XfburnPreferencesDialog * obj) { GtkBox *box = GTK_BOX (GTK_DIALOG (obj)->vbox); XfburnPreferencesDialogPrivate *priv = XFBURN_PREFERENCES_DIALOG_GET_PRIVATE (obj); GtkWidget *vbox, *vbox2, *vbox3, *hbox; GtkWidget *label; GtkWidget *frame; GtkWidget *scrolled_window; GtkListStore *icon_store, *store; gint x,y; GdkPixbuf *icon = NULL; GtkTreeIter iter; GtkTreeViewColumn *column_name; GtkCellRenderer *cell_icon, *cell_name; GtkWidget *button_close; gint idx; gtk_window_set_title (GTK_WINDOW (obj), _("Preferences")); xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (obj), _("Tune how Xfburn behaves")); gtk_window_set_default_size (GTK_WINDOW (obj), 775, 400); gtk_window_set_destroy_with_parent (GTK_WINDOW (obj), TRUE); gtk_window_set_icon_name (GTK_WINDOW (obj), GTK_STOCK_PREFERENCES); gtk_dialog_set_has_separator (GTK_DIALOG (obj), FALSE); hbox = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (box, hbox, TRUE, TRUE, 0); gtk_widget_show (hbox); scrolled_window = gtk_scrolled_window_new (NULL, NULL); g_object_set (G_OBJECT (scrolled_window), "hscrollbar-policy", GTK_POLICY_NEVER, "shadow-type", GTK_SHADOW_IN, "vscrollbar-policy", GTK_POLICY_NEVER, NULL); gtk_box_pack_start (GTK_BOX (hbox), scrolled_window, FALSE, FALSE, 0); gtk_widget_show (scrolled_window); /* icon bar */ icon_store = gtk_list_store_new (SETTINGS_LIST_N_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT); priv->icon_bar = exo_icon_bar_new_with_model (GTK_TREE_MODEL (icon_store)); exo_icon_bar_set_pixbuf_column (EXO_ICON_BAR (priv->icon_bar), SETTINGS_LIST_PIXBUF_COLUMN); exo_icon_bar_set_text_column (EXO_ICON_BAR (priv->icon_bar), SETTINGS_LIST_TEXT_COLUMN); gtk_container_add (GTK_CONTAINER (scrolled_window), priv->icon_bar); gtk_widget_show (priv->icon_bar); /* notebook */ priv->notebook = gtk_notebook_new (); gtk_container_set_border_width (GTK_CONTAINER (priv->notebook), BORDER); g_object_set (G_OBJECT (priv->notebook), "show-border", FALSE, "show-tabs", FALSE, NULL); gtk_box_pack_start (GTK_BOX (hbox), priv->notebook, TRUE, TRUE, BORDER); gtk_widget_show (priv->notebook); /* general tab */ vbox = gtk_vbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox), BORDER); idx = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), vbox, NULL); gtk_widget_show (vbox); vbox2 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox2); frame = xfce_gtk_frame_box_new_with_content (_("Temporary directory"), vbox2); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, BORDER); gtk_widget_show (frame); priv->chooser_button = gtk_file_chooser_button_new (_("Temporary directory"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); gtk_box_pack_start (GTK_BOX (vbox2), priv->chooser_button, FALSE, FALSE, BORDER); gtk_widget_show (priv->chooser_button); priv->check_clean_tmpdir = gtk_check_button_new_with_mnemonic (_("_Clean temporary directory on exit")); gtk_box_pack_start (GTK_BOX (vbox2), priv->check_clean_tmpdir, FALSE, FALSE, BORDER); gtk_widget_show (priv->check_clean_tmpdir); vbox2 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox2); frame = xfce_gtk_frame_box_new_with_content (_("File browser"), vbox2); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, BORDER); gtk_widget_show (frame); priv->check_show_hidden = gtk_check_button_new_with_mnemonic (_("Show _hidden files")); gtk_box_pack_start (GTK_BOX (vbox2), priv->check_show_hidden, FALSE, FALSE, BORDER); gtk_widget_show (priv->check_show_hidden); g_signal_connect (G_OBJECT (priv->check_show_hidden), "clicked", G_CALLBACK (cb_show_hidden_clicked), NULL); priv->check_show_human_readable = gtk_check_button_new_with_mnemonic (_("Show human_readable filesizes")); gtk_box_pack_start (GTK_BOX (vbox2), priv->check_show_human_readable, FALSE, FALSE, BORDER); gtk_widget_show (priv->check_show_human_readable); icon = gtk_widget_render_icon (GTK_WIDGET (priv->icon_bar), GTK_STOCK_PROPERTIES, GTK_ICON_SIZE_DIALOG, NULL); gtk_list_store_append (icon_store, &iter); gtk_list_store_set (icon_store, &iter, SETTINGS_LIST_PIXBUF_COLUMN, icon, SETTINGS_LIST_TEXT_COLUMN, _("General"), SETTINGS_LIST_INDEX_COLUMN, idx, -1); g_object_unref (G_OBJECT (icon)); /* devices tab */ vbox = gtk_vbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox), BORDER); idx = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), vbox, NULL); gtk_widget_show (vbox); label = gtk_label_new (_("Devices")); gtk_widget_show (label); gtk_notebook_set_tab_label (GTK_NOTEBOOK (priv->notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), 1), label); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); vbox2 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox2); frame = xfce_gtk_frame_box_new_with_content (_("Detected devices"), vbox2); gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, BORDER); gtk_widget_show (frame); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN); gtk_widget_show (scrolled_window); gtk_box_pack_start (GTK_BOX (vbox2), scrolled_window, TRUE, TRUE, BORDER); store = gtk_list_store_new (DEVICE_LIST_N_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN); priv->treeview_devices = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), DEVICE_LIST_COLUMN_NAME, GTK_SORT_ASCENDING); gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (priv->treeview_devices), TRUE); gtk_widget_show (priv->treeview_devices); gtk_container_add (GTK_CONTAINER (scrolled_window), priv->treeview_devices); g_object_unref (store); /* add columns */ column_name = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column_name, _("Name")); gtk_tree_view_column_set_expand (column_name, TRUE); cell_icon = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_pack_start (column_name, cell_icon, FALSE); gtk_tree_view_column_set_attributes (column_name, cell_icon, "pixbuf", DEVICE_LIST_COLUMN_ICON, NULL); g_object_set (cell_icon, "xalign", 0.0, "ypad", 0, NULL); cell_name = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column_name, cell_name, TRUE); gtk_tree_view_column_set_attributes (column_name, cell_name, "text", DEVICE_LIST_COLUMN_NAME, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (priv->treeview_devices), column_name); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Node"), gtk_cell_renderer_text_new (), "text", DEVICE_LIST_COLUMN_NODE, NULL); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Write CD-R"), gtk_cell_renderer_toggle_new (), "active", DEVICE_LIST_COLUMN_CDR, NULL); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Write CD-RW"), gtk_cell_renderer_toggle_new (), "active", DEVICE_LIST_COLUMN_CDRW, NULL); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Write DVD-R"), gtk_cell_renderer_toggle_new (), "active", DEVICE_LIST_COLUMN_DVDR, NULL); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Write DVD-RAM"), gtk_cell_renderer_toggle_new (), "active", DEVICE_LIST_COLUMN_DVDRAM, NULL); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Write Blu-ray"), gtk_cell_renderer_toggle_new (), "active", DEVICE_LIST_COLUMN_BD, NULL); hbox = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, BORDER); gtk_widget_show (hbox); priv->button_scan = xfce_gtk_button_new_mixed (GTK_STOCK_CDROM, _("Sc_an for devices")); gtk_box_pack_end (GTK_BOX (hbox), priv->button_scan, FALSE, FALSE, BORDER); g_signal_connect (G_OBJECT (priv->button_scan), "clicked", G_CALLBACK (scan_button_clicked_cb), obj); gtk_widget_show (priv->button_scan); gtk_icon_size_lookup (GTK_ICON_SIZE_DIALOG, &x, &y); icon = gtk_icon_theme_load_icon ( gtk_icon_theme_get_default(), "media-optical", x, GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL); if (!icon) icon = gtk_icon_theme_load_icon ( gtk_icon_theme_get_default(), "media-cdrom", x, GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL); if (!icon) icon = gtk_icon_theme_load_icon ( gtk_icon_theme_get_default(), GTK_STOCK_CDROM, x, GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL); gtk_list_store_append (icon_store, &iter); gtk_list_store_set (icon_store, &iter, SETTINGS_LIST_PIXBUF_COLUMN, icon, SETTINGS_LIST_TEXT_COLUMN, _("Devices"), SETTINGS_LIST_INDEX_COLUMN, idx, -1); if (icon) g_object_unref (G_OBJECT (icon)); exo_mutual_binding_new (G_OBJECT (priv->notebook), "page", G_OBJECT (priv->icon_bar), "active"); /* below the device list */ #if 0 priv->check_empty_speed_list = gtk_check_button_new_with_mnemonic (_("Show warning on _empty speed list")); gtk_box_pack_start (GTK_BOX (vbox2), priv->check_empty_speed_list, FALSE, FALSE, BORDER); gtk_widget_show (priv->check_empty_speed_list); #endif /* fifo */ vbox3 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox3); frame = xfce_gtk_frame_box_new_with_content (_("FIFO buffer size (in kb)"), vbox3); gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, BORDER); gtk_widget_show (frame); priv->scale_fifo = gtk_hscale_new_with_range (0.0, FIFO_MAX_SIZE, 32.0); gtk_scale_set_value_pos (GTK_SCALE (priv->scale_fifo), GTK_POS_LEFT); gtk_range_set_value (GTK_RANGE (priv->scale_fifo), 0); gtk_box_pack_start (GTK_BOX (vbox3), priv->scale_fifo, FALSE, FALSE, BORDER/2); gtk_widget_show (priv->scale_fifo); /* action buttons */ button_close = gtk_button_new_from_stock ("gtk-close"); gtk_widget_show (button_close); gtk_dialog_add_action_widget (GTK_DIALOG (obj), button_close, GTK_RESPONSE_CLOSE); GTK_WIDGET_SET_FLAGS (button_close, GTK_CAN_DEFAULT); gtk_widget_grab_focus (button_close); gtk_widget_grab_default (button_close); g_signal_connect (G_OBJECT (obj), "response", G_CALLBACK (xfburn_preferences_dialog_response_cb), priv); refresh_devices_list (obj); g_object_unref (icon_store); }
static GtkWidget * get_voice_test_frame(PurplePlugin *plugin) { GtkWidget *vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); GtkWidget *level = gtk_progress_bar_new(); GtkWidget *volume = gtk_hscale_new_with_range(0, 100, 1); GtkWidget *threshold = gtk_hscale_new_with_range(0, 100, 1); GtkWidget *label; GtkTable *table = GTK_TABLE(gtk_table_new(2, 2, FALSE)); GstElement *pipeline; GstBus *bus; BusCbCtx *ctx; g_object_set(vbox, "width-request", 500, NULL); gtk_table_set_row_spacings(table, PIDGIN_HIG_BOX_SPACE); gtk_table_set_col_spacings(table, PIDGIN_HIG_BOX_SPACE); label = gtk_label_new(_("Volume:")); g_object_set(label, "xalign", 0.0, NULL); gtk_table_attach(table, label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); gtk_table_attach_defaults(table, volume, 1, 2, 0, 1); label = gtk_label_new(_("Silence threshold:")); g_object_set(label, "xalign", 0.0, "yalign", 1.0, NULL); gtk_table_attach(table, label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0); gtk_table_attach_defaults(table, threshold, 1, 2, 1, 2); gtk_container_add(GTK_CONTAINER(vbox), level); gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(table)); gtk_widget_show_all(vbox); pipeline = create_pipeline(); bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline)); gst_bus_add_signal_watch(bus); ctx = g_new(BusCbCtx, 1); ctx->level = GTK_PROGRESS_BAR(level); ctx->threshold = GTK_RANGE(threshold); g_signal_connect_data(bus, "message", G_CALLBACK(gst_bus_cb), ctx, (GClosureNotify)g_free, 0); gst_object_unref(bus); g_signal_connect(volume, "value-changed", (GCallback)on_volume_change_cb, pipeline); gtk_range_set_value(GTK_RANGE(volume), purple_prefs_get_int("/purple/media/audio/volume/input")); gtk_widget_set(volume, "draw-value", FALSE, NULL); gtk_range_set_value(GTK_RANGE(threshold), purple_prefs_get_int("/purple/media/audio/silence_threshold")); g_signal_connect(vbox, "destroy", G_CALLBACK(voice_test_frame_destroy_cb), pipeline); g_signal_connect(volume, "destroy", G_CALLBACK(volume_scale_destroy_cb), NULL); g_signal_connect(threshold, "format-value", G_CALLBACK(threshold_value_format_cb), NULL); g_signal_connect(threshold, "destroy", G_CALLBACK(threshold_scale_destroy_cb), NULL); return vbox; }
void lightdash_configure (XfcePanelPlugin *plugin, LightdashPlugin *lightdash) { GtkWidget *dialog; GtkWidget *hbox; GtkWidget *label; GtkWidget *entry; GtkWidget *opacity_slider; GtkWidget *show_desktop_button; GtkWidget *toplevel; GtkWindow *window; window = NULL; toplevel = gtk_widget_get_toplevel (GTK_WIDGET (plugin)); if (gtk_widget_is_toplevel (toplevel)) { window = GTK_WINDOW (toplevel); } xfce_panel_plugin_block_menu (plugin); dialog = xfce_titled_dialog_new_with_buttons (_("lightdash"), window, GTK_DIALOG_DESTROY_WITH_PARENT #if GTK_CHECK_VERSION (3, 0, 0) #else | GTK_DIALOG_NO_SEPARATOR #endif , GTK_STOCK_HELP, GTK_RESPONSE_HELP, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); #if GTK_CHECK_VERSION (3, 0, 0) hbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); #else hbox = gtk_hbox_new (FALSE, 0); #endif label = gtk_label_new_with_mnemonic (_("_Title:")); entry = gtk_entry_new (); gtk_entry_set_text (GTK_ENTRY (entry), gtk_label_get_text (GTK_LABEL (lightdash->button_label))); g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (lightdash_preferences_entry_changed), lightdash); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox, TRUE, TRUE, 6); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 6); gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 6); gtk_widget_show_all (hbox); #if GTK_CHECK_VERSION (3, 0, 0) hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); #else hbox = gtk_hbox_new (FALSE, 0); #endif opacity_slider = gtk_hscale_new_with_range (0.0, 100.0, 1.0); gtk_scale_set_value_pos (GTK_SCALE (opacity_slider), GTK_POS_RIGHT); gtk_widget_set_size_request (GTK_WIDGET (opacity_slider), 200, -1); gtk_range_set_value (GTK_RANGE (opacity_slider), lightdash->opacity); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox, TRUE, TRUE, 6); label = gtk_label_new_with_mnemonic (_("Background opacit_y:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 6); gtk_box_pack_start (GTK_BOX (hbox), opacity_slider, TRUE, TRUE, 6); g_signal_connect (G_OBJECT (opacity_slider), "value-changed", G_CALLBACK (lightdash_opacity_slider_changed), lightdash); gtk_widget_show_all (hbox); show_desktop_button = gtk_check_button_new_with_label (_("Show desktop behind dashboard")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (show_desktop_button), lightdash->show_desktop); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), show_desktop_button, TRUE, TRUE, 6); g_signal_connect (G_OBJECT (show_desktop_button), "toggled", G_CALLBACK (lightdash_show_desktop_button_toggled), lightdash); g_object_set_data (G_OBJECT (plugin), "dialog", dialog); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (lightdash_configure_response), lightdash); gtk_widget_show_all (dialog); }
static void module_selected(GtkTreeSelection * ts, gpointer data) { ShellTree *shelltree = shell->tree; GtkTreeModel *model = GTK_TREE_MODEL(shelltree->model); GtkTreeIter parent; ShellModuleEntry *entry; static ShellModuleEntry *current = NULL; static gboolean updating = FALSE; if (updating) return; updating = TRUE; /* Gets the currently selected item on the left-side TreeView; if there is no selection, silently return */ if (!gtk_tree_selection_get_selected(ts, &model, &parent)) return; /* Mark the currently selected module as "unselected"; this is used to kill the update timeout. */ if (current) current->selected = FALSE; /* Get the current selection and shows its related info */ gtk_tree_model_get(model, &parent, TREE_COL_DATA, &entry, -1); if (entry && entry->func && !entry->selected) { shell_status_set_enabled(TRUE); shell_status_update("Updating..."); entry->selected = TRUE; shell->selected = entry; module_selected_show_info(entry, FALSE); info_selected_show_extra(NULL); /* clears the more info store */ gtk_tree_view_columns_autosize(GTK_TREE_VIEW(shell->info->view)); /* urgh. why don't GTK do this when the model is cleared? */ gtk_range_set_value(GTK_RANGE(GTK_SCROLLED_WINDOW(shell->info->scroll)->vscrollbar), 0.0); gtk_range_set_value(GTK_RANGE(GTK_SCROLLED_WINDOW(shell->info->scroll)->hscrollbar), 0.0); gtk_range_set_value(GTK_RANGE(GTK_SCROLLED_WINDOW(shell->moreinfo->scroll)->vscrollbar), 0.0); gtk_range_set_value(GTK_RANGE(GTK_SCROLLED_WINDOW(shell->moreinfo->scroll)->hscrollbar), 0.0); shell_status_update("Done."); shell_status_set_enabled(FALSE); gchar *tmp = g_strdup_printf("%s - System Information", entry->name); gtk_window_set_title(GTK_WINDOW(shell->window), tmp); g_free(tmp); shell_action_set_enabled("RefreshAction", entry->reloadfunc ? TRUE : FALSE); } else { gtk_window_set_title(GTK_WINDOW(shell->window), "System Information"); shell_action_set_enabled("RefreshAction", FALSE); gtk_tree_store_clear(GTK_TREE_STORE(shell->info->model)); set_view_type(SHELL_VIEW_NORMAL); } current = entry; updating = FALSE; }
static void preset_button_clicked(GtkButton *button, gpointer data) { gint clevel = GPOINTER_TO_INT(data); gtk_range_set_value(GTK_RANGE(feed_slider), clevel >> 16); gtk_range_set_value(GTK_RANGE(fcut_slider), clevel & 0xffff); }
static void _lib_lighttable_set_zoom(dt_lib_module_t *self, gint zoom) { dt_lib_tool_lighttable_t *d = (dt_lib_tool_lighttable_t *)self->data; gtk_range_set_value(GTK_RANGE(d->zoom), zoom); }
void lamixer_volbox_changevalue(GtkWidget *volbar, glong value, gulong hsignalid) { g_signal_handler_block(G_OBJECT(volbar), hsignalid); gtk_range_set_value(GTK_RANGE(volbar), value); g_signal_handler_unblock (G_OBJECT(volbar), hsignalid); }
GtkWidget* bimp_watermark_gui_new(watermark_settings settings) { GtkWidget *gui, *hbox_text_entry, *hbox_text_font, *hbox_text_color, *hbox_opacity, *frame_position, *table_position; GtkWidget *align_radio_text, *align_radio_image; GtkWidget *label_text, *label_font, *label_color, *label_opacity, *label_percent; gui = gtk_vbox_new(FALSE, 5); align_radio_text = gtk_alignment_new(0, 0, 0, 0); gtk_alignment_set_padding(GTK_ALIGNMENT(align_radio_text), 0, 5, 10, 0); radio_text = gtk_radio_button_new_with_label(NULL, _("Text watermark")); vbox_text = gtk_vbox_new(FALSE, 5); hbox_text_entry = gtk_hbox_new(FALSE, 5); label_text = gtk_label_new(g_strconcat(_("Text"), ":", NULL)); gtk_widget_set_size_request (label_text, LABEL_W, LABEL_H); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_text), settings->mode); entry_text = gtk_entry_new(); gtk_entry_set_max_length(GTK_ENTRY(entry_text), 50); gtk_entry_set_text(GTK_ENTRY(entry_text), settings->text); gtk_widget_set_size_request (entry_text, INPUT_W, INPUT_H); hbox_text_font = gtk_hbox_new(FALSE, 5); label_font = gtk_label_new(g_strconcat(_("Font"), ":", NULL)); gtk_widget_set_size_request (label_font, LABEL_W, LABEL_H); chooser_font = gtk_font_button_new_with_font(pango_font_description_to_string(settings->font)); gtk_widget_set_size_request (chooser_font, INPUT_W, INPUT_H); hbox_text_color = gtk_hbox_new(FALSE, 5); label_color = gtk_label_new(g_strconcat(_("Color"), ":", NULL)); gtk_widget_set_size_request (label_color, LABEL_W, LABEL_H); chooser_color = gtk_color_button_new_with_color(&(settings->color)); gtk_widget_set_size_request (chooser_color, INPUT_W, INPUT_H); align_radio_image = gtk_alignment_new(0, 0, 0, 0); gtk_alignment_set_padding(GTK_ALIGNMENT(align_radio_image), 0, 5, 10, 0); radio_image = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON(radio_text), _("Image watermark")); vbox_image = gtk_vbox_new(FALSE, 5); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_image), !settings->mode); chooser_image = gtk_file_chooser_button_new(_("Select image"), GTK_FILE_CHOOSER_ACTION_OPEN); /* set image chooser's filters */ GtkFileFilter *filter_all, *supported[5]; filter_all = gtk_file_filter_new(); gtk_file_filter_set_name(filter_all, _("All supported types")); supported[0] = gtk_file_filter_new(); gtk_file_filter_set_name(supported[0], "Bitmap (*.bmp)"); gtk_file_filter_add_pattern (supported[0], "*.bmp"); gtk_file_filter_add_pattern (filter_all, "*.bmp"); supported[1] = gtk_file_filter_new(); gtk_file_filter_set_name(supported[1], "JPEG (*.jpg, *.jpeg, *jpe)"); gtk_file_filter_add_pattern (supported[1], "*.jpg"); gtk_file_filter_add_pattern (supported[1], "*.jpeg"); gtk_file_filter_add_pattern (supported[1], "*.jpe"); gtk_file_filter_add_pattern (filter_all, "*.jpg"); gtk_file_filter_add_pattern (filter_all, "*.jpeg"); gtk_file_filter_add_pattern (filter_all, "*.jpe"); supported[2] = gtk_file_filter_new(); gtk_file_filter_set_name(supported[2], "GIF (*.gif)"); gtk_file_filter_add_pattern (supported[2], "*.gif"); gtk_file_filter_add_pattern (filter_all, "*.gif"); supported[3] = gtk_file_filter_new(); gtk_file_filter_set_name(supported[3], "PNG (*.png)"); gtk_file_filter_add_pattern (supported[3], "*.png"); gtk_file_filter_add_pattern (filter_all, "*.png"); supported[4] = gtk_file_filter_new(); gtk_file_filter_set_name(supported[4], "TIFF (*tif, *.tiff)"); gtk_file_filter_add_pattern (supported[4], "*.tiff"); gtk_file_filter_add_pattern (supported[4], "*.tif"); gtk_file_filter_add_pattern (filter_all, "*.tiff"); gtk_file_filter_add_pattern (filter_all, "*.tif"); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser_image), filter_all); int i; for(i = 0; i < 5; i++) { gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser_image), supported[i]); } if (settings->image_file != NULL) { gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(chooser_image), settings->image_file); } gtk_widget_set_size_request (chooser_image, INPUT_W, INPUT_H); hbox_opacity = gtk_hbox_new(FALSE, 5); label_opacity = gtk_label_new(g_strconcat(_("Opacity"), ":", NULL)); gtk_widget_set_size_request (label_opacity, LABEL_TRANSP_W, LABEL_TRANSP_H); gtk_misc_set_alignment(GTK_MISC(label_opacity), 0.5, 0.8); scale_opacity = gtk_hscale_new_with_range(1, 100, 1); gtk_range_set_value(GTK_RANGE(scale_opacity), settings->opacity); gtk_widget_set_size_request (scale_opacity, SCALE_TRANSP_W, SCALE_TRANSP_H); label_percent = gtk_label_new("%"); gtk_widget_set_size_request (label_percent, LABEL_PERCENT_W, LABEL_PERCENT_H); gtk_misc_set_alignment(GTK_MISC(label_percent), 0.5, 0.8); frame_position = gtk_frame_new(g_strconcat(_("Position on the image"), ":", NULL)); gtk_widget_set_size_request (frame_position, FRAME_POSITION_W, FRAME_POSITION_H); table_position = gtk_table_new(3, 3, TRUE); button_tl = gtk_radio_button_new (NULL); gtk_button_set_image(GTK_BUTTON(button_tl), gtk_image_new_from_pixbuf(gdk_pixbuf_from_pixdata(&pixdata_postl, TRUE, NULL))); gtk_widget_set_tooltip_text (button_tl, watermark_pos_get_string(WM_POS_TL)); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button_tl), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_tl), settings->position == WM_POS_TL); gtk_widget_set_size_request (button_tl, BUTTON_POSITION_W, BUTTON_POSITION_H); gtk_table_attach(GTK_TABLE(table_position), button_tl, 0, 1, 0, 1, GTK_EXPAND, GTK_EXPAND, 0, 0); button_tc = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON(button_tl)); gtk_button_set_image(GTK_BUTTON(button_tc), gtk_image_new_from_pixbuf(gdk_pixbuf_from_pixdata(&pixdata_postc, TRUE, NULL))); gtk_widget_set_tooltip_text (button_tc, watermark_pos_get_string(WM_POS_TC)); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button_tc), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_tc), settings->position == WM_POS_TC); gtk_widget_set_size_request (button_tc, BUTTON_POSITION_W, BUTTON_POSITION_H); gtk_table_attach(GTK_TABLE(table_position), button_tc, 1, 2, 0, 1, GTK_EXPAND, GTK_EXPAND, 0, 0); button_tr = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON(button_tl)); gtk_button_set_image(GTK_BUTTON(button_tr), gtk_image_new_from_pixbuf(gdk_pixbuf_from_pixdata(&pixdata_postr, TRUE, NULL))); gtk_widget_set_tooltip_text (button_tr, watermark_pos_get_string(WM_POS_TR)); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button_tr), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_tr), settings->position == WM_POS_TR); gtk_widget_set_size_request (button_tr, BUTTON_POSITION_W, BUTTON_POSITION_H); gtk_table_attach(GTK_TABLE(table_position), button_tr, 2, 3, 0, 1, GTK_EXPAND, GTK_EXPAND, 0, 0); button_cl = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON(button_tl)); gtk_button_set_image(GTK_BUTTON(button_cl), gtk_image_new_from_pixbuf(gdk_pixbuf_from_pixdata(&pixdata_poscl, TRUE, NULL))); gtk_widget_set_tooltip_text (button_cl, watermark_pos_get_string(WM_POS_CL)); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button_cl), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_cl), settings->position == WM_POS_CL); gtk_widget_set_size_request (button_cl, BUTTON_POSITION_W, BUTTON_POSITION_H); gtk_table_attach(GTK_TABLE(table_position), button_cl, 0, 1, 1, 2, GTK_EXPAND, GTK_EXPAND, 0, 0); button_cc = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON(button_tl)); gtk_button_set_image(GTK_BUTTON(button_cc), gtk_image_new_from_pixbuf(gdk_pixbuf_from_pixdata(&pixdata_poscc, TRUE, NULL))); gtk_widget_set_tooltip_text (button_cc, watermark_pos_get_string(WM_POS_CC)); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button_cc), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_cc), settings->position == WM_POS_CC); gtk_widget_set_size_request (button_cc, BUTTON_POSITION_W, BUTTON_POSITION_H); gtk_table_attach(GTK_TABLE(table_position), button_cc, 1, 2, 1, 2, GTK_EXPAND, GTK_EXPAND, 0, 0); button_cr = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON(button_tl)); gtk_button_set_image(GTK_BUTTON(button_cr), gtk_image_new_from_pixbuf(gdk_pixbuf_from_pixdata(&pixdata_poscr, TRUE, NULL))); gtk_widget_set_tooltip_text (button_cr, watermark_pos_get_string(WM_POS_CR)); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button_cr), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_cr), settings->position == WM_POS_CR); gtk_widget_set_size_request (button_cr, BUTTON_POSITION_W, BUTTON_POSITION_H); gtk_table_attach(GTK_TABLE(table_position), button_cr, 2, 3, 1, 2, GTK_EXPAND, GTK_EXPAND, 0, 0); button_bl = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON(button_tl)); gtk_button_set_image(GTK_BUTTON(button_bl), gtk_image_new_from_pixbuf(gdk_pixbuf_from_pixdata(&pixdata_posbl, TRUE, NULL))); gtk_widget_set_tooltip_text (button_bl, watermark_pos_get_string(WM_POS_BL)); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button_bl), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_bl), settings->position == WM_POS_BL); gtk_widget_set_size_request (button_bl, BUTTON_POSITION_W, BUTTON_POSITION_H); gtk_table_attach(GTK_TABLE(table_position), button_bl, 0, 1, 2, 3, GTK_EXPAND, GTK_EXPAND, 0, 0); button_bc = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON(button_tl)); gtk_button_set_image(GTK_BUTTON(button_bc), gtk_image_new_from_pixbuf(gdk_pixbuf_from_pixdata(&pixdata_posbc, TRUE, NULL))); gtk_widget_set_tooltip_text (button_bc, watermark_pos_get_string(WM_POS_BC)); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button_bc), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_bc), settings->position == WM_POS_BC); gtk_widget_set_size_request (button_bc, BUTTON_POSITION_W, BUTTON_POSITION_H); gtk_table_attach(GTK_TABLE(table_position), button_bc, 1, 2, 2, 3, GTK_EXPAND, GTK_EXPAND, 0, 0); button_br = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON(button_tl)); gtk_button_set_image(GTK_BUTTON(button_br), gtk_image_new_from_pixbuf(gdk_pixbuf_from_pixdata(&pixdata_posbr, TRUE, NULL))); gtk_widget_set_tooltip_text (button_br, watermark_pos_get_string(WM_POS_BR)); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button_br), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_br), settings->position == WM_POS_BR); gtk_widget_set_size_request (button_br, BUTTON_POSITION_W, BUTTON_POSITION_H); gtk_table_attach(GTK_TABLE(table_position), button_br, 2, 3, 2, 3, GTK_EXPAND, GTK_EXPAND, 0, 0); gtk_box_pack_start(GTK_BOX(gui), radio_text, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox_text_entry), label_text, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox_text_entry), entry_text, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox_text_font), label_font, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox_text_font), chooser_font, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox_text_color), label_color, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox_text_color), chooser_color, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox_text), hbox_text_entry, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox_text), hbox_text_font, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox_text), hbox_text_color, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(align_radio_text), vbox_text); gtk_box_pack_start(GTK_BOX(gui), align_radio_text, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(gui), radio_image, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox_image), chooser_image, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(align_radio_image), vbox_image); gtk_box_pack_start(GTK_BOX(gui), align_radio_image, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox_opacity), label_opacity, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox_opacity), scale_opacity, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox_opacity), label_percent, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(gui), hbox_opacity, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(frame_position), table_position); gtk_box_pack_start(GTK_BOX(gui), frame_position, FALSE, FALSE, 0); toggle_group(NULL, NULL); g_signal_connect(G_OBJECT(radio_text), "toggled", G_CALLBACK(toggle_group), NULL); return gui; }
static void draw_controls (VidState *s) { int i; if (s->control) { for (i = 0; i < s->num_controls; i++) { ControlInfo * ci = s->control_info + i; if (ci->widget) gtk_widget_destroy (ci->widget); if (ci->label) gtk_widget_destroy (ci->label); if (ci->labelval) gtk_widget_destroy (ci->labelval); } free (s->control_info); s->control_info = NULL; input_free_controls (s->control, s->num_controls); s->control = NULL; } s->control = input_enum_controls (videoIn, &s->num_controls); //fprintf(stderr,"V4L2_CID_BASE=0x%x\n",V4L2_CID_BASE); //fprintf(stderr,"V4L2_CID_PRIVATE_BASE=0x%x\n",V4L2_CID_PRIVATE_BASE); //fprintf(stderr,"V4L2_CID_PRIVATE_LAST=0x%x\n",V4L2_CID_PRIVATE_LAST); fprintf(stderr,"Controls:\n"); for (i = 0; i < s->num_controls; i++) { fprintf(stderr,"control[%d]: 0x%x",i,s->control[i].id); fprintf (stderr," %s, %d:%d:%d, default %d\n", s->control[i].name, s->control[i].min, s->control[i].step, s->control[i].max, s->control[i].default_val); } if((s->control_info = malloc (s->num_controls * sizeof (ControlInfo)))==NULL){ printf("couldn't allocate memory for: s->control_info\n"); exit(1); } for (i = 0; i < s->num_controls; i++) { ControlInfo * ci = s->control_info + i; InputControl * c = s->control + i; ci->idx = i; ci->widget = NULL; ci->label = NULL; ci->labelval = NULL; if (c->id == V4L2_CID_EXPOSURE_AUTO) { int val; ci->widget = gtk_check_button_new_with_label (c->name); g_object_set_data (G_OBJECT (ci->widget), "control_info", ci); gtk_widget_show (ci->widget); gtk_table_attach (GTK_TABLE (s->table), ci->widget, 1, 3, 3+i, 4+i, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0, 0); if (input_get_control (videoIn, c, &val) == 0) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ci->widget), val==AUTO_EXP ? TRUE : FALSE); } else { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ci->widget), c->default_val==AUTO_EXP ? TRUE : FALSE); gtk_widget_set_sensitive (ci->widget, FALSE); } if (!c->enabled) { gtk_widget_set_sensitive (ci->widget, FALSE); } g_signal_connect (G_OBJECT (ci->widget), "toggled", G_CALLBACK (check_changed), s); } else if (c->type == INPUT_CONTROL_TYPE_INTEGER) { PangoFontDescription * desc; int val; if (c->step == 0) c->step = 1; ci->widget = gtk_hscale_new_with_range (c->min, c->max, c->step); gtk_scale_set_draw_value (GTK_SCALE (ci->widget), FALSE); /* This is a hack to use always round the HScale to integer * values. Strangely, this functionality is normally only * available when draw_value is TRUE. */ GTK_RANGE (ci->widget)->round_digits = 0; gtk_table_attach (GTK_TABLE (s->table), ci->widget, 1, 2, 3+i, 4+i, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0, 0); g_object_set_data (G_OBJECT (ci->widget), "control_info", ci); ci->maxchars = MAX (num_chars (c->min), num_chars (c->max)); gtk_widget_show (ci->widget); ci->labelval = gtk_label_new (NULL); gtk_table_attach (GTK_TABLE (s->table), ci->labelval, 2, 3, 3+i, 4+i, GTK_FILL, 0, 0, 0); desc = pango_font_description_new (); pango_font_description_set_family_static (desc, "monospace"); gtk_widget_modify_font (ci->labelval, desc); gtk_misc_set_alignment (GTK_MISC (ci->labelval), 1, 0.5); if (input_get_control (videoIn, c, &val) == 0) { gtk_range_set_value (GTK_RANGE (ci->widget), val); } else { gtk_range_set_value (GTK_RANGE (ci->widget), c->default_val); gtk_widget_set_sensitive (ci->widget, FALSE); gtk_widget_set_sensitive (ci->labelval, FALSE); } if (!c->enabled) { gtk_widget_set_sensitive (ci->widget, FALSE); gtk_widget_set_sensitive (ci->labelval, FALSE); } set_slider_label (GTK_RANGE (ci->widget)); g_signal_connect (G_OBJECT (ci->widget), "value-changed", G_CALLBACK (slider_changed), s); gtk_widget_show (ci->labelval); ci->label = gtk_label_new (g_strdup_printf ("%s:", c->name)); } else if (c->type == INPUT_CONTROL_TYPE_BOOLEAN) { int val; ci->widget = gtk_check_button_new_with_label (c->name); g_object_set_data (G_OBJECT (ci->widget), "control_info", ci); gtk_widget_show (ci->widget); gtk_table_attach (GTK_TABLE (s->table), ci->widget, 1, 3, 3+i, 4+i, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0, 0); if (input_get_control (videoIn, c, &val) == 0) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ci->widget), val ? TRUE : FALSE); } else { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ci->widget), c->default_val ? TRUE : FALSE); gtk_widget_set_sensitive (ci->widget, FALSE); } if (!c->enabled) { gtk_widget_set_sensitive (ci->widget, FALSE); } g_signal_connect (G_OBJECT (ci->widget), "toggled", G_CALLBACK (check_changed), s); } else if (c->type == INPUT_CONTROL_TYPE_MENU) { int val, j; ci->widget = gtk_combo_box_new_text (); for (j = 0; j <= c->max; j++) { gtk_combo_box_append_text (GTK_COMBO_BOX (ci->widget), c->entries[j]); } gtk_table_attach (GTK_TABLE (s->table), ci->widget, 1, 3, 3+i, 4+i, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0, 0); g_object_set_data (G_OBJECT (ci->widget), "control_info", ci); gtk_widget_show (ci->widget); if (input_get_control (videoIn, c, &val) == 0) { gtk_combo_box_set_active (GTK_COMBO_BOX (ci->widget), val); } else { gtk_combo_box_set_active (GTK_COMBO_BOX (ci->widget), c->default_val); gtk_widget_set_sensitive (ci->widget, FALSE); } if (!c->enabled) { gtk_widget_set_sensitive (ci->widget, FALSE); } g_signal_connect (G_OBJECT (ci->widget), "changed", G_CALLBACK (combo_changed), s); ci->label = gtk_label_new (g_strdup_printf ("%s:", c->name)); } else { fprintf (stderr, "TODO: implement menu and button\n"); continue; } if (ci->label) { gtk_misc_set_alignment (GTK_MISC (ci->label), 1, 0.5); gtk_table_attach (GTK_TABLE (s->table), ci->label, 0, 1, 3+i, 4+i, GTK_FILL, 0, 0, 0); gtk_widget_show (ci->label); } } }
void idol_setup_preferences (Idol *idol) { GtkWidget *menu, *content_area; gboolean show_visuals, auto_resize, is_local, no_deinterlace, lock_screensaver_on_audio, auto_chapters; int connection_speed; guint i, hidden; char *visual, *font, *encoding; GList *list, *l; BvwAudioOutType audio_out; MateConfValue *value; GObject *item; static struct { const char *name; BvwVideoProperty prop; const char *label; } props[4] = { { "tpw_contrast_scale", BVW_VIDEO_CONTRAST, "tpw_contrast_label" }, { "tpw_saturation_scale", BVW_VIDEO_SATURATION, "tpw_saturation_label" }, { "tpw_bright_scale", BVW_VIDEO_BRIGHTNESS, "tpw_brightness_label" }, { "tpw_hue_scale", BVW_VIDEO_HUE, "tpw_hue_label" } }; g_return_if_fail (idol->gc != NULL); is_local = idol_display_is_local (); mateconf_client_add_dir (idol->gc, MATECONF_PREFIX, MATECONF_CLIENT_PRELOAD_ONELEVEL, NULL); mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/auto_resize", (MateConfClientNotifyFunc) auto_resize_changed_cb, idol, NULL, NULL); mateconf_client_add_dir (idol->gc, "/desktop/mate/lockdown", MATECONF_CLIENT_PRELOAD_ONELEVEL, NULL); /* Work-around builder dialogue not parenting properly for * On top windows */ item = gtk_builder_get_object (idol->xml, "tpw_notebook"); idol->prefs = gtk_dialog_new_with_buttons (_("Preferences"), GTK_WINDOW (idol->win), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CLOSE, GTK_RESPONSE_ACCEPT, NULL); gtk_container_set_border_width (GTK_CONTAINER (idol->prefs), 5); content_area = gtk_dialog_get_content_area (GTK_DIALOG (idol->prefs)); gtk_box_set_spacing (GTK_BOX (content_area), 2); gtk_widget_reparent (GTK_WIDGET (item), content_area); gtk_widget_show_all (content_area); item = gtk_builder_get_object (idol->xml, "idol_preferences_window"); gtk_widget_destroy (GTK_WIDGET (item)); g_signal_connect (G_OBJECT (idol->prefs), "response", G_CALLBACK (gtk_widget_hide), NULL); g_signal_connect (G_OBJECT (idol->prefs), "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), NULL); g_signal_connect (idol->prefs, "destroy", G_CALLBACK (gtk_widget_destroyed), &idol->prefs); /* Remember position */ idol->remember_position = mateconf_client_get_bool (idol->gc, MATECONF_PREFIX"/remember_position", NULL); item = gtk_builder_get_object (idol->xml, "tpw_remember_position_checkbutton"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), idol->remember_position); mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/remember_position", (MateConfClientNotifyFunc) remember_position_changed_cb, idol, NULL, NULL); /* Auto-resize */ auto_resize = mateconf_client_get_bool (idol->gc, MATECONF_PREFIX"/auto_resize", NULL); item = gtk_builder_get_object (idol->xml, "tpw_display_checkbutton"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), auto_resize); bacon_video_widget_set_auto_resize (BACON_VIDEO_WIDGET (idol->bvw), auto_resize); /* Screensaver audio locking */ lock_screensaver_on_audio = mateconf_client_get_bool (idol->gc, MATECONF_PREFIX"/lock_screensaver_on_audio", NULL); if (lock_screensaver_on_audio != FALSE) item = gtk_builder_get_object (idol->xml, "tpw_audio_toggle_button"); else item = gtk_builder_get_object (idol->xml, "tpw_video_toggle_button"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), TRUE); mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/lock_screensaver_on_audio", (MateConfClientNotifyFunc) lock_screensaver_on_audio_changed_cb, idol, NULL, NULL); /* Disable deinterlacing */ item = gtk_builder_get_object (idol->xml, "tpw_no_deinterlace_checkbutton"); no_deinterlace = mateconf_client_get_bool (idol->gc, MATECONF_PREFIX"/disable_deinterlacing", NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), no_deinterlace); bacon_video_widget_set_deinterlacing (idol->bvw, !no_deinterlace); mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/disable_deinterlacing", (MateConfClientNotifyFunc) no_deinterlace_changed_cb, idol, NULL, NULL); /* Connection Speed */ connection_speed = bacon_video_widget_get_connection_speed (idol->bvw); item = gtk_builder_get_object (idol->xml, "tpw_speed_combobox"); gtk_combo_box_set_active (GTK_COMBO_BOX (item), connection_speed); /* Enable visuals */ item = gtk_builder_get_object (idol->xml, "tpw_visuals_checkbutton"); show_visuals = mateconf_client_get_bool (idol->gc, MATECONF_PREFIX"/show_vfx", NULL); if (is_local == FALSE && show_visuals != FALSE) show_visuals = ask_show_visuals (idol); g_signal_handlers_disconnect_by_func (item, checkbutton2_toggled_cb, idol); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), show_visuals); idol_prefs_set_show_visuals (idol, show_visuals); g_signal_connect (item, "toggled", G_CALLBACK (checkbutton2_toggled_cb), idol); mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/show_vfx", (MateConfClientNotifyFunc) show_vfx_changed_cb, idol, NULL, NULL); /* Auto-load subtitles */ item = gtk_builder_get_object (idol->xml, "tpw_auto_subtitles_checkbutton"); idol->autoload_subs = mateconf_client_get_bool (idol->gc, MATECONF_PREFIX"/autoload_subtitles", NULL); g_signal_handlers_disconnect_by_func (item, checkbutton3_toggled_cb, idol); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), idol->autoload_subs); g_signal_connect (item, "toggled", G_CALLBACK (checkbutton3_toggled_cb), idol); mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/autoload_subtitles", (MateConfClientNotifyFunc) autoload_subtitles_changed_cb, idol, NULL, NULL); /* Auto-load external chapters */ item = gtk_builder_get_object (idol->xml, "tpw_auto_chapters_checkbutton"); auto_chapters = mateconf_client_get_bool (idol->gc, MATECONF_PREFIX"/autoload_chapters", NULL); g_signal_handlers_disconnect_by_func (item, auto_chapters_toggled_cb, idol); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), auto_chapters); g_signal_connect (item, "toggled", G_CALLBACK (auto_chapters_toggled_cb), idol); mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/autoload_chapters", (MateConfClientNotifyFunc) autoload_chapters_changed_cb, idol, NULL, NULL); /* Visuals list */ list = bacon_video_widget_get_visuals_list (idol->bvw); menu = gtk_menu_new (); gtk_widget_show (menu); visual = mateconf_client_get_string (idol->gc, MATECONF_PREFIX"/visual", NULL); if (visual == NULL || strcmp (visual, "") == 0) { g_free (visual); visual = g_strdup ("goom"); } item = gtk_builder_get_object (idol->xml, "tpw_visuals_type_combobox"); i = 0; for (l = list; l != NULL; l = l->next) { const char *name = l->data; gtk_combo_box_append_text (GTK_COMBO_BOX (item), name); if (strcmp (name, visual) == 0) gtk_combo_box_set_active (GTK_COMBO_BOX (item), i); i++; } g_free (visual); /* Visualisation quality */ i = mateconf_client_get_int (idol->gc, MATECONF_PREFIX"/visual_quality", NULL); bacon_video_widget_set_visuals_quality (idol->bvw, i); item = gtk_builder_get_object (idol->xml, "tpw_visuals_size_combobox"); gtk_combo_box_set_active (GTK_COMBO_BOX (item), i); /* Brightness and all */ hidden = 0; for (i = 0; i < G_N_ELEMENTS (props); i++) { int prop_value; item = gtk_builder_get_object (idol->xml, props[i].name); prop_value = bacon_video_widget_get_video_property (idol->bvw, props[i].prop); if (prop_value >= 0) gtk_range_set_value (GTK_RANGE (item), (gdouble) prop_value); else { gtk_range_set_value (GTK_RANGE (item), (gdouble) 65535/2); gtk_widget_hide (GTK_WIDGET (item)); item = gtk_builder_get_object (idol->xml, props[i].label); gtk_widget_hide (GTK_WIDGET (item)); hidden++; } } if (hidden == G_N_ELEMENTS (props)) { item = gtk_builder_get_object (idol->xml, "tpw_bright_contr_vbox"); gtk_widget_hide (GTK_WIDGET (item)); } /* Sound output type */ item = gtk_builder_get_object (idol->xml, "tpw_sound_output_combobox"); audio_out = bacon_video_widget_get_audio_out_type (idol->bvw); gtk_combo_box_set_active (GTK_COMBO_BOX (item), audio_out); /* Subtitle font selection */ item = gtk_builder_get_object (idol->xml, "font_sel_button"); gtk_font_button_set_title (GTK_FONT_BUTTON (item), _("Select Subtitle Font")); font = mateconf_client_get_string (idol->gc, MATECONF_PREFIX"/subtitle_font", NULL); if (font && strcmp (font, "") != 0) { gtk_font_button_set_font_name (GTK_FONT_BUTTON (item), font); bacon_video_widget_set_subtitle_font (idol->bvw, font); } g_free (font); mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/subtitle_font", (MateConfClientNotifyFunc) font_changed_cb, idol, NULL, NULL); /* Subtitle encoding selection */ item = gtk_builder_get_object (idol->xml, "subtitle_encoding_combo"); idol_subtitle_encoding_init (GTK_COMBO_BOX (item)); value = mateconf_client_get_without_default (idol->gc, MATECONF_PREFIX"/subtitle_encoding", NULL); /* Make sure the default is UTF-8 */ if (value != NULL) { if (mateconf_value_get_string (value) == NULL) { encoding = g_strdup ("UTF-8"); } else { encoding = g_strdup (mateconf_value_get_string (value)); if (encoding[0] == '\0') { g_free (encoding); encoding = g_strdup ("UTF-8"); } } mateconf_value_free (value); } else { encoding = g_strdup ("UTF-8"); } idol_subtitle_encoding_set (GTK_COMBO_BOX(item), encoding); if (encoding && strcasecmp (encoding, "") != 0) { bacon_video_widget_set_subtitle_encoding (idol->bvw, encoding); } g_free (encoding); mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/subtitle_encoding", (MateConfClientNotifyFunc) encoding_changed_cb, idol, NULL, NULL); /* Disable keyboard shortcuts */ idol->disable_kbd_shortcuts = mateconf_client_get_bool (idol->gc, MATECONF_PREFIX"/disable_keyboard_shortcuts", NULL); mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/disable_keyboard_shortcuts", (MateConfClientNotifyFunc) disable_kbd_shortcuts_changed_cb, idol, NULL, NULL); }
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); }
int gtkui_run_dialog (GtkWidget *parentwin, ddb_dialog_t *conf, uint32_t buttons, int (*callback)(int button, void *ctx), void *ctx) { if (!parentwin) { parentwin = mainwin; } // create window char title[200]; snprintf (title, sizeof (title), _("Configure %s"), conf->title); GtkWidget *win; if (!buttons) { win = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parentwin), GTK_DIALOG_MODAL, GTK_STOCK_APPLY, GTK_RESPONSE_APPLY, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response (GTK_DIALOG (win), GTK_RESPONSE_OK); } else { win = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parentwin), GTK_DIALOG_MODAL, NULL); if (buttons & (1<<ddb_button_ok)) { gtk_dialog_add_button (GTK_DIALOG (win), GTK_STOCK_OK, GTK_RESPONSE_OK); } if (buttons & (1<<ddb_button_cancel)) { gtk_dialog_add_button (GTK_DIALOG (win), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); } if (buttons & (1<<ddb_button_close)) { gtk_dialog_add_button (GTK_DIALOG (win), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); } if (buttons & (1<<ddb_button_apply)) { gtk_dialog_add_button (GTK_DIALOG (win), GTK_STOCK_APPLY, GTK_RESPONSE_APPLY); } if (buttons & (1<<ddb_button_yes)) { gtk_dialog_add_button (GTK_DIALOG (win), GTK_STOCK_YES, GTK_RESPONSE_YES); } if (buttons & (1<<ddb_button_no)) { gtk_dialog_add_button (GTK_DIALOG (win), GTK_STOCK_NO, GTK_RESPONSE_NO); } } gtk_window_set_type_hint (GTK_WINDOW (win), GDK_WINDOW_TYPE_HINT_DIALOG); gtk_container_set_border_width (GTK_CONTAINER(win), 12); gtk_window_set_title (GTK_WINDOW (win), title); gtk_window_set_modal (GTK_WINDOW (win), TRUE); gtk_window_set_transient_for (GTK_WINDOW (win), GTK_WINDOW (parentwin)); GtkWidget *widgets[100] = {NULL}; int pack[100] = {0}; int ncurr = 0; widgets[ncurr] = gtk_dialog_get_content_area (GTK_DIALOG (win)); gtk_box_set_spacing (GTK_BOX (widgets[ncurr]), 8); GtkWidget *action_area = gtk_dialog_get_action_area (GTK_DIALOG (win)); gtk_widget_show (action_area); gtk_button_box_set_layout (GTK_BUTTON_BOX (action_area), GTK_BUTTONBOX_END); // parse script char token[MAX_TOKEN]; const char *script = conf->layout; parser_line = 1; while (script = gettoken (script, token)) { if (strcmp (token, "property")) { fprintf (stderr, "invalid token while loading plugin %s config dialog: %s at line %d\n", conf->title, token, parser_line); break; } char labeltext[MAX_TOKEN]; script = gettoken_warn_eof (script, labeltext); if (!script) { break; } if (ncurr > 0) { pack[ncurr]--; if (pack[ncurr] < 0) { ncurr--; } } char type[MAX_TOKEN]; script = gettoken_warn_eof (script, type); if (!script) { break; } if (!strncmp (type, "hbox[", 5) || !strncmp (type, "vbox[", 5)) { ncurr++; int n = 0; if (1 != sscanf (type+4, "[%d]", &n)) { break; } pack[ncurr] = n; int vert = 0; int hmg = FALSE; int fill = FALSE; int expand = FALSE; int border = 0; int spacing = 8; int height = 100; char param[MAX_TOKEN]; for (;;) { script = gettoken_warn_eof (script, param); if (!script) { break; } if (!strcmp (param, ";")) { break; } else if (!strcmp (param, "hmg")) { hmg = TRUE; } else if (!strcmp (param, "fill")) { fill = TRUE; } else if (!strcmp (param, "expand")) { expand = TRUE; } else if (!strncmp (param, "border=", 7)) { border = atoi (param+7); } else if (!strncmp (param, "spacing=", 8)) { spacing = atoi (param+8); } else if (!strncmp (param, "height=", 7)) { height = atoi (param+7); } } widgets[ncurr] = vert ? gtk_vbox_new (TRUE, spacing) : gtk_hbox_new (TRUE, spacing); gtk_widget_set_size_request (widgets[ncurr], -1, height); gtk_widget_show (widgets[ncurr]); gtk_box_pack_start (GTK_BOX(widgets[ncurr-1]), widgets[ncurr], fill, expand, border); continue; } int vertical = 0; char key[MAX_TOKEN]; for (;;) { script = gettoken_warn_eof (script, key); if (!script) { break; } if (!strcmp (key, "vert")) { vertical = 1; } else { break; } } char def[MAX_TOKEN]; script = gettoken_warn_eof (script, def); if (!script) { break; } // add to dialog GtkWidget *label = NULL; GtkWidget *prop = NULL; GtkWidget *cont = NULL; char value[1000]; conf->get_param (key, value, sizeof (value), def); if (!strcmp (type, "entry") || !strcmp (type, "password")) { label = gtk_label_new (_(labeltext)); gtk_widget_show (label); prop = gtk_entry_new (); gtk_entry_set_activates_default (GTK_ENTRY (prop), TRUE); g_signal_connect (G_OBJECT (prop), "changed", G_CALLBACK (prop_changed), win); gtk_widget_show (prop); gtk_entry_set_text (GTK_ENTRY (prop), value); if (!strcmp (type, "password")) { gtk_entry_set_visibility (GTK_ENTRY (prop), FALSE); } } else if (!strcmp (type, "checkbox")) { prop = gtk_check_button_new_with_label (_(labeltext)); g_signal_connect (G_OBJECT (prop), "toggled", G_CALLBACK (prop_changed), win); gtk_widget_show (prop); int val = atoi (value); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prop), val); } else if (!strcmp (type, "file")) { label = gtk_label_new (_(labeltext)); gtk_widget_show (label); if (deadbeef->conf_get_int ("gtkui.pluginconf.use_filechooser_button", 0)) { prop = gtk_file_chooser_button_new (_(labeltext), GTK_FILE_CHOOSER_ACTION_OPEN); gtk_widget_show (prop); gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (prop), value); g_signal_connect (G_OBJECT (prop), "file-set", G_CALLBACK (prop_changed), win); } else { cont = gtk_hbox_new (FALSE, 2); gtk_widget_show (cont); prop = gtk_entry_new (); gtk_entry_set_activates_default (GTK_ENTRY (prop), TRUE); g_signal_connect (G_OBJECT (prop), "changed", G_CALLBACK (prop_changed), win); gtk_widget_show (prop); gtk_editable_set_editable (GTK_EDITABLE (prop), FALSE); gtk_entry_set_text (GTK_ENTRY (prop), value); gtk_box_pack_start (GTK_BOX (cont), prop, TRUE, TRUE, 0); GtkWidget *btn = gtk_button_new_with_label ("…"); gtk_widget_show (btn); gtk_box_pack_start (GTK_BOX (cont), btn, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (btn), "clicked", G_CALLBACK (on_prop_browse_file), prop); } } else if (!strncmp (type, "select[", 7)) { int n; if (1 != sscanf (type+6, "[%d]", &n)) { break; } label = gtk_label_new (_(labeltext)); gtk_widget_show (label); prop = gtk_combo_box_text_new (); gtk_widget_show (prop); for (int i = 0; i < n; i++) { char entry[MAX_TOKEN]; script = gettoken_warn_eof (script, entry); if (!script) { break; } gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (prop), entry); } if (!script) { break; } gtk_combo_box_set_active (GTK_COMBO_BOX (prop), atoi (value)); g_signal_connect ((gpointer) prop, "changed", G_CALLBACK (prop_changed), win); } else if (!strncmp (type, "hscale[", 7) || !strncmp (type, "vscale[", 7) || !strncmp (type, "spinbtn[", 8)) { float min, max, step; const char *args; if (type[0] == 's') { args = type + 7; } else { args = type + 6; } if (3 != sscanf (args, "[%f,%f,%f]", &min, &max, &step)) { break; } int invert = 0; if (min >= max) { float tmp = min; min = max; max = tmp; invert = 1; } if (step <= 0) { step = 1; } if (type[0] == 's') { prop = gtk_spin_button_new_with_range (min, max, step); gtk_spin_button_set_value (GTK_SPIN_BUTTON (prop), atof (value)); } else { prop = type[0] == 'h' ? gtk_hscale_new_with_range (min, max, step) : gtk_vscale_new_with_range (min, max, step); if (invert) { gtk_range_set_inverted (GTK_RANGE (prop), TRUE); } gtk_range_set_value (GTK_RANGE (prop), (gdouble)atof (value)); gtk_scale_set_value_pos (GTK_SCALE (prop), GTK_POS_RIGHT); } label = gtk_label_new (_(labeltext)); gtk_widget_show (label); g_signal_connect (G_OBJECT (prop), "value-changed", G_CALLBACK (prop_changed), win); gtk_widget_show (prop); } script = gettoken_warn_eof (script, token); if (!script) { break; } if (strcmp (token, ";")) { fprintf (stderr, "expected `;' while loading plugin %s config dialog: %s at line %d\n", conf->title, token, parser_line); break; } if (label && prop) { GtkWidget *hbox = NULL; hbox = vertical ? gtk_vbox_new (FALSE, 8) : gtk_hbox_new (FALSE, 8); gtk_widget_show (hbox); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), cont ? cont : prop, TRUE, TRUE, 0); cont = hbox; } else { cont = prop; } if (prop) { g_object_set_data (G_OBJECT (win), key, prop); } if (cont) { gtk_box_pack_start (GTK_BOX (widgets[ncurr]), cont, FALSE, FALSE, 0); } } int response; do { gtk_dialog_set_response_sensitive (GTK_DIALOG (win), GTK_RESPONSE_APPLY, FALSE); response = gtk_dialog_run (GTK_DIALOG (win)); if (response == GTK_RESPONSE_APPLY || response == GTK_RESPONSE_OK) { apply_conf (win, conf); } if (callback) { int btn = ddb_button_from_gtk_response (response); if (!callback (btn, ctx)) { break; } } } while (response == GTK_RESPONSE_APPLY); gtk_widget_destroy (win); int btn = ddb_button_from_gtk_response (response); return btn; }