void mixer_properties(Mixer * mixer) { GtkSizeGroup * group; GtkWidget * vbox; GtkWidget * hbox; MixerProperties mp; if(mixer->properties != NULL) { gtk_widget_show(mixer->properties); return; } if(mixer_get_properties(mixer, &mp) != 0) return; mixer->properties = gtk_message_dialog_new(GTK_WINDOW(mixer->window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, #if GTK_CHECK_VERSION(2, 6, 0) "%s", _("Properties")); gtk_message_dialog_format_secondary_text( GTK_MESSAGE_DIALOG(mixer->properties), #endif ""); #if GTK_CHECK_VERSION(2, 10, 0) gtk_message_dialog_set_image(GTK_MESSAGE_DIALOG(mixer->properties), gtk_image_new_from_icon_name("gtk-properties", GTK_ICON_SIZE_DIALOG)); #endif gtk_window_set_title(GTK_WINDOW(mixer->properties), _("Properties")); g_signal_connect(mixer->properties, "delete-event", G_CALLBACK( _properties_on_closex), NULL); g_signal_connect(mixer->properties, "response", G_CALLBACK( gtk_widget_hide), NULL); #if GTK_CHECK_VERSION(2, 14, 0) vbox = gtk_dialog_get_content_area(GTK_DIALOG(mixer->properties)); #else vbox = GTK_DIALOG(mixer->properties)->vbox; #endif group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); hbox = _properties_label(mixer, group, _("Name: "), mp.name); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 2); hbox = _properties_label(mixer, group, _("Version: "), mp.version); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); hbox = _properties_label(mixer, group, _("Device: "), mp.device); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 2); gtk_widget_show_all(vbox); gtk_widget_show(mixer->properties); }
static void _properties_window(Camera * camera) { GtkWidget * dialog; GtkSizeGroup * group; GtkWidget * vbox; GtkWidget * hbox; char buf[64]; const struct { unsigned int capability; char const * name; } capabilities[] = { { V4L2_CAP_VIDEO_CAPTURE, "capture" }, { V4L2_CAP_VIDEO_OUTPUT, "output" }, { V4L2_CAP_VIDEO_OVERLAY, "overlay" }, { V4L2_CAP_TUNER, "tuner" }, { V4L2_CAP_AUDIO, "audio" }, { V4L2_CAP_STREAMING, "streaming" }, { 0, NULL } }; unsigned int i; char const * sep = ""; dialog = gtk_message_dialog_new(GTK_WINDOW(camera->window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, #if GTK_CHECK_VERSION(2, 6, 0) "%s", _("Properties")); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), #endif ""); camera->pp_window = dialog; #if GTK_CHECK_VERSION(2, 10, 0) gtk_message_dialog_set_image(GTK_MESSAGE_DIALOG(dialog), gtk_image_new_from_stock(GTK_STOCK_PROPERTIES, GTK_ICON_SIZE_DIALOG)); #endif gtk_window_set_title(GTK_WINDOW(dialog), _("Properties")); g_signal_connect_swapped(dialog, "response", G_CALLBACK( _properties_on_response), camera); group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); #if GTK_CHECK_VERSION(2, 14, 0) vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); #else vbox = dialog->vbox; #endif /* driver */ snprintf(buf, sizeof(buf), "%-16s", (char *)camera->cap.driver); hbox = _properties_label(camera, group, _("Driver: "), buf); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); /* card */ snprintf(buf, sizeof(buf), "%-32s", (char *)camera->cap.card); hbox = _properties_label(camera, group, _("Card: "), buf); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); /* bus info */ snprintf(buf, sizeof(buf), "%-32s", (char *)camera->cap.bus_info); hbox = _properties_label(camera, group, _("Bus info: "), buf); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); /* version */ snprintf(buf, sizeof(buf), "0x%x", camera->cap.version); hbox = _properties_label(camera, group, _("Version: "), buf); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); /* capabilities */ buf[0] = '\0'; for(i = 0; capabilities[i].name != NULL; i++) if(camera->cap.capabilities & capabilities[i].capability) { strncat(buf, sep, sizeof(buf) - strlen(buf)); strncat(buf, capabilities[i].name, sizeof(buf) - strlen(buf)); sep = ", "; } buf[sizeof(buf) - 1] = '\0'; hbox = _properties_label(camera, group, _("Capabilities: "), buf); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); gtk_widget_show_all(vbox); }